PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, December 5, 2022

[FIXED] How to create universal function for insert in database oci

 December 05, 2022     oci8, php     No comments   

Issue

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


Solution

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.



Answered By - user3661564
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing