Bug #10843 Updated: Function creates new array but does not reset pointer
| From: | kalowsky@php.net | Date: | Wed, 22 May 2002 02:56:58 +0000 |
| Subject: | Bug #10843 Updated: Function creates new array but does not reset pointer | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-8144@lists.php.net to get a copy of this message | ||
ID: 10843
Updated by: kalowsky@php.net
Reported By: peter@petermoulding.com
-Status: Open
+Status: Closed
Bug Type: ODBC related
Operating System: NT 4.0 sp6
PHP Version: 4.0.5
New Comment:
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at
http://www.php.net/downloads.php
Previous Comments:
------------------------------------------------------------------------
[2001-06-11 22:35:19] kalowsky@php.net
comment from user:
That patch is all Greek to me. I will have to find a
compiler and learn how to
compile. Is there any chance of putting it in the
updates at php4win or www.zend.com/snapshots
php4win posted an update 4.0.7 2001-06-11 so I tested that
and still same
problem. 4.0.7 produced a strange result. The
code:
while($result_all = odbc_fetch_into($result, 0, $array))
produces:
Fatal error: Only variables can be passed by reference
The following works:
$zero = 0;
while($result_all = odbc_fetch_into($result, $zero,
$array))
$zero remains at 0 so is not updated.
------------------------------------------------------------------------
[2001-06-11 11:03:57] kalowsky@php.net
can you please try this patch with a current build of PHP?
Index: php_odbc.c
===================================================================
RCS file: /repository/php4/ext/odbc/php_odbc.c,v
retrieving revision 1.92
diff -u -r1.92 php_odbc.c
--- php_odbc.c 11 Jun 2001 01:00:43 -0000 1.92
+++ php_odbc.c 11 Jun 2001 15:04:36 -0000
@@ -1489,6 +1489,9 @@
}
zend_hash_index_update((*pv_res_arr)->value.ht, i,
&tmp, sizeof(pval *), NULL);
}
+
+ zend_hash_internal_pointer_reset((*pv_res_arr)->value.ht);
+
if (buf) efree(buf);
RETURN_LONG(result->numcols);
}
------------------------------------------------------------------------
[2001-06-01 13:48:32] peter@petermoulding.com
The database happened to be Access. I have MySQL and PostgeSQL
available through ODBC and MySQL direct. I though the action to
odbc_fetch_into() would be the same no matter which database.
Normally when a function returns an array, the pointer is at the start.
Perhaps this is the result of passing an array by reference and what is
needed is a documentation change to highlight what happens to the
pointer.
------------------------------------------------------------------------
[2001-06-01 11:57:16] kalowsky@php.net
what database is this with?
------------------------------------------------------------------------
[2001-05-13 23:03:45] peter@petermoulding.com
I tried odbc_fetch_into() in the enclosed loop. I had to inset the
reset($array) to get the loop working. I figure the function is
creating new content in the array but not resetting the array pointer
back to the beginning. The function should either
1/ add to the end of the array and increment the pointer
or
2/ replace the contents and reset the pointer.
$sql = "select * from stock";
$result = odbc_exec($connection["vitamins"], $sql);
if($result)
{
print("<br>Result from odbc_fetch_into()" );
$array = "";
while($result_all = odbc_fetch_into($result, 0, $array))
{
reset($array);
print("<br>" );
while(list($k, $v) = each($array))
{
print($v . " ");
}
}
}
else
{
print("<br>No result" );
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=10843&edit=1