ID: 14238 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Bogus Bug Type: ODBC related Operating System: NT 4.0 Workstation - SP6 PHP Version: 4.0.6 New Comment:
Thank you for taking the time to report a problem with PHP. Unfortunately your version of PHP is too old -- the problem might already be fixed. Please download a new PHP version from http://www.php.net/downloads.php If you are able to reproduce the bug with one of the latest versions of PHP, please change the PHP version on this bug report to the version you tested and change the status back to "Open". Again, thank you for your continued support of PHP. Previous Comments: ------------------------------------------------------------------------ [2001-11-26 12:25:10] [EMAIL PROTECTED] While working on a class to encapsulate ODBC functionality, I discovered a problem in calling odbc_fetch_into with an array that exists inside a class. I was creating an array in the class to hold the results of the current row, and allowing the user of the class to reference the fields from there. It looked a little like this: class DB { var $record = array(); var $queryid; ... function fetch_row() { return(odbc_fetch_into($this->queryid, $this->record) } ... } When I tried to display the results from $record with something like echo $myDB->record[0];, all that is displayed is "Array[0]" (w/o quotes). After some tinkering, I modified the "fetch_row()" function in my class to accept an array parameter: function fetch_row($myarray) { return(odbc_fetch_into($this->queryid, $myarray) } This corrected the problem, although I have to give up my encapsulation. Now echo $myarray[0]; displays the appropriate data. So it appears that there is a conflict with encapsulated arrays and odbc_fetch_into. I believe that there was a similiar problem with the MS SQL extension a while back (mid version 3 around 3.0.12 or so). I'm accessing an MS Access 97 database through Microsoft's ODBC driver. A fully functional example follows. Greg Sohl Cedar Rapids, IA Here is a fully functional example of what works and what doesn't work. Its as short as I could get it and keep it understandable. <html><body> <table border="1"> <tr><td>ID</td><td>Name</td><td>Email</td></tr> <? // For testing simple array encapsulation class Results { var $record = array(); } $dblink = odbc_connect('ftp_reg', '', ''); $queryid = odbc_exec($dblink, "select * from Test"); // 3 columns /* This technique works - Calling odbc_fetch_into with a global array */ $my_array = array(); while(odbc_fetch_into($queryid, $my_array)) echo "<tr><td>$my_array[0]</td><td>$my_array[1]</td><td>$my_array[2]</td></tr>"; odbc_fetch_row($queryid, 0); // Reset to the begininning /* This technique does not work - Calling odbc_fetch_into with an array in a class */ $my_results = new Results(); while(odbc_fetch_into($queryid, $my_results->record)) echo "<tr><td>$my_results->record[0]</td><td>$my_results->record[1]</td><td>$my_results->record[2]</td></tr>"; ?> </table></body></html> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=14238&edit=1