0

I create universal function for insert in Oracle database but is not working correctly.

function Insert($conn,$sqlText,$arrayInput){
    if (!$conn) {
        $e = oci_error();
        trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
    }

    $stid = oci_parse($conn,$sqlText);

     //   echo '<pre>' . print_r($arrayVariables, true) . '</pre>';
    foreach($arrayInput as $key=>$var)
    {
        // echo 'varable='.$key.'<br/>'.'value='.$var.'</br>';
        oci_bind_by_name($stid,$key,$var);
    }
    oci_execute($stid);

    oci_commit($conn);
    oci_free_statement($stid);
    oci_close($conn);   
}

Any idea why is not working? I cant find way to see what is sending to oracle by executing oci_execute($stid);. or what is binded

10
  • Any error in oracle log?
    – frz3993
    Jan 5, 2016 at 15:59
  • not working Exactly how is it not working?
    – RiggsFolly
    Jan 5, 2016 at 16:16
  • No i did not find any errors in alert log or listner log.However Warning: oci_execute(): ORA-01722: invalid number in /var/www/html/tutorial/functions/Normalization.php on line 22 is occur when I execute one insert with more than one parameter Jan 5, 2016 at 16:37
  • $conn=oci_connect('papa', 'papa', 'tst'); $sqlText='insert into TU_CONTEN(tu_title,tu_text,tu_position,topic_id) values (:title,:text,:position,(select tu_id from PAPA.TU_TOPIC where topic=:topic))'; $arrayInput1[":title"]=$Title; $arrayInput1[":text"]=$TextEntry; $arrayInput1[":position"]=$maxPosition; $arrayInput1[":topic"]=$_SESSION['topic']; Insert($conn, $sqlText, $arrayInput1); -- this one is not working Jan 5, 2016 at 16:38
  • I create function again Jan 6, 2016 at 20:20

1 Answer 1

0

Basically values of array are always string even if I add it as int. So I add check for is_number which solve issue. Thanks for all which try to help me if somebody know why array did not keep int values will be great to share.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.