Stored Procedure:
parentchildhrs number(7,0);
childhours number(7,0);
begin
COMBINED_HOURS(122,parentchildhrs,childhours);
end;
The above when executed via Oracle SQL Developer
outputs the correct expected value which are hours. Output below
CHILD HOURS 50
parent task id 122
parentchild HOURS 100
Now when I call with PHP-OCI, it outputs nothing.
$taskID = 122;
$parent_hours = '';
$child_hours = '';
$procedure = "BEGIN TASK_COMBINED_CHILD_HRS(:task_id, :parent_child_hours, :child_hours); END;";
$test = $taskmaster->getHours($procedure, [':task_id' => $taskID,':parent_child_hours' => (int)$sum_parent_child_hours,':child_hours' => (int)$sum_child_hours]);
public function getHours($query, $params){
$result_hours = parent::ocibindbyname($query, $params);
return $result_hours;
}
public static function customquery($query, $params)
{
try{
$stmt = oci_parse($conn, $query);
foreach ($params as $key => &$value) {
oci_bind_by_name($stmt, $key, $value, 32);
}
oci_execute($stmt,OCI_COMMIT_ON_SUCCESS);
oci_commit($conn);
oci_free_statement($stmt);
return $params;
}catch (Exception $e){
print_r($e);
}
}
Printing the result gives
Array
(
[:task_id] => 1142
[:parent_child_hours] => 100
[:child_hours] => 50
)
- How can I bind a PHP variable for
parent_child_hours
andchild_hours
as output from a stored procedure variable ?