Results 1 to 1 of 1
  1. #1
    Join Date
    Jul 2006

    Unanswered: oci_fetch_all vs. ocifetchstatement [COMPATIBILITY ISSUE]


    I've developed some piece of software locally using up-to-date PHP5 and Apache 2.2. This software is PHP/Oracle.
    [Edited] Oops, sorry. Guess I forgot to mention that I had to host the application in a server that runs PHP4 and an older Apache server.
    All my database related functions are now PHP5 standard. Like oci_fetch_all instead of ocifetchstatement, oci_parse instead of ociparse, and so on.

    So what I did was to create an include file that goes in all my php pages and this include file contains compatibility functions. I was just trying to make it work on both enviroments. I've been smacking my head for so long now I might get Parkinson.

    Here are my working functions (maybe it'll help someone).

    PHP Code:
    # oci_parse
    if (!function_exists("oci_parse")) {
    # Custom Function
    function oci_parse($connection$string_query) {

    # oci_execute
    if (!function_exists("oci_execute")) {
    # Custom Function
    function oci_execute($statement$mode OCI_COMMIT_ON_SUCCESS) {

    # stripos
    if (!function_exists("stripos")) {
    # Custom Function
    function stripos($str$needle$offset 0) {
    strpos(strtolower($str), strtolower($needle), $offset);

    if (!function_exists("str_ireplace")) {
    # Custom Function
    function str_ireplace($needle$replacement$haystack) {
    $i 0;
           while ((
    $pos strpos(strtolower($haystack), strtolower($needle), $i)) !== false) {
    $haystack substr($haystack0$pos) . $replacement substr($haystack$pos strlen($needle));
    $i $pos strlen($replacement);

    Those are all working fine. Trouble comes with oci_fetch_all ...

    PHP Code:
    # oci_fetch_all
    if (!function_exists("oci_fetch_all")) {
    # Custom Function
    function oci_fetch_all($statement$output$skip 0$maxrows = -1$flags OCI_FETCHSTATEMENT_BY_COLUMN) {

    This won't work. The error I get is undefined variable in the line in which the oci_fetch_all is called. For example:

    PHP Code:
    1.        # 1. Parse & Execute
    2.        $Query_Statement oci_parse($conn$statement);
    3.        oci_execute($Query_Statement);
    # 2. Fetch
    6.        $Return["Rows"] = oci_fetch_all($Query_Statement$Return["RS"], $QF_Init$QF_PageSize$QF_Flag); 

    This would return me an error in line 6: undefined Variable Return (...). I understand why it doesn't work. Because the oci_fetch_all was supposed to set the $Return["RS"] variable with the fetched Result Set, but when the new custom function is called $Return["RS"] is just an unset variable. Also this function actually returns the total records found (either columns or rows). So I know that my Custom Function can't just return the deprecated function, but I can't figure out how to solve that.

    Is there any other way to rename a function, or copy it to another function name or something like that?

    I know it looks nooby, but I tried something like oci_fetch_all = ocifetchstatement; out of pure despair.

    Any help will be very much appreciated.
    Last edited by igordonin; 04-01-08 at 09:26.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts