madcapone Posted March 31, 2008 Share Posted March 31, 2008 Hi! I've developed some piece of software locally using up-to-date PHP5 and Apache 2.2. This software is PHP/Oracle. 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). # oci_parse if (!function_exists("oci_parse")) { # Custom Function function oci_parse($connection, $string_query) { return ociparse($connection, $string_query); } } # # oci_execute if (!function_exists("oci_execute")) { # Custom Function function oci_execute($statement, $mode = OCI_COMMIT_ON_SUCCESS) { return ociexecute($statement, $mode); } } # # stripos if (!function_exists("stripos")) { # Custom Function function stripos($str, $needle, $offset = 0) { return strpos(strtolower($str), strtolower($needle), $offset); } } # #str_ireplace 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($haystack, 0, $pos) . $replacement . substr($haystack, $pos + strlen($needle)); $i = $pos + strlen($replacement); } return $haystack; } } # Those are all working fine. Trouble comes with oci_fetch_all ... # 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) { return ocifetchstatement($statement, $output, $skip, $maxrows, $flags); } } # This won't work. The error I get is undefined variable in the line in which the oci_fetch_all is called. For example: 1. # 1. Parse & Execute 2. $Query_Statement = oci_parse($conn, $statement); 3. oci_execute($Query_Statement); 4. 5. # 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. Link to comment https://forums.phpfreaks.com/topic/98879-oci_fetch_all-vs-ocifetchstatement-compatibility-issue/ Share on other sites More sharing options...
madcapone Posted April 1, 2008 Author Share Posted April 1, 2008 *BUMP* Link to comment https://forums.phpfreaks.com/topic/98879-oci_fetch_all-vs-ocifetchstatement-compatibility-issue/#findComment-506458 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.