Home » Database » DB » Bug #4190
fetchInto On MSSQL In DB_FETCHMODE_ASSOC Broken
Details
| Submitted | 2005-04-20 16:41 UTC |
|---|---|
| From | therebel at free dot fr |
| Assigned | danielc |
| Status | Bogus |
| Package | DB |
| PHP Version | 4.3.10 |
| OS | Linux Debian |
| Roadmaps | (Not assigned) |
Comments
[2005-04-20 16:41 UTC] therebel at free dot fr
Description:
------------
On SQL SERVER 2000,with package php4-sybase.deb installed, fetchInto in DB_FETCHMODE_ASSOC return nothing
Reproduce code:
---------------
$sql = " SELECT * FROM table ";
$result = $db->query($sql);
$result->fetchInto($dataRow,);
=> Return nothing !!
$result->fetchInto($dataRow);
=> Return something !
Problem on DB_FETCHMODE_ASSOC : In mssql.php, mssql_fetch_array isn't used with correct parameters...
Here my patch :
[mssql.php]
function fetchInto($result, &$arr, $fetchmode, $rownum = null)
{
if ($rownum !== null) {
if (!@mssql_data_seek($result, $rownum)) {
return null;
}
}
if ($fetchmode & DB_FETCHMODE_ASSOC) {
$arr = mssql_fetch_assoc($result); //=>HERE @mssql_fetch_array replaced
if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
$arr = array_change_key_case($arr, CASE_LOWER);
}
} else {
$arr = @mssql_fetch_row($result);
}
if (!$arr) {
return null;
}
if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
$this->_rtrimArrayValues($arr);
}
if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) {
$this->_convertNullArrayValuesToEmpty($arr);
}
return DB_OK;
}
Expected result:
----------------
An assoc array of Data
Actual result:
--------------
nothing (nor error message because of @) I think it's a problem of different behavior of mssql_fetch_array with Sybase package
[2005-04-20 16:50 UTC] therebel at free dot fr
It was just a probem of PHP compilation : It was compiled with sybase-ct support (that also add mssql_* functions to php) instead of mssql
'../configure' '--prefix=/usr' '--with-apxs=/usr/bin/apxs' '--with-regex=php' '--with-config-file-path=/etc/php4/apache' '--disable-rpath' '--enable-memory-limit' '--disable-debug' '--with-layout=GNU' '--with-pear=/usr/share/php' '--enable-calendar' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable-trans-sid' '--enable-bcmath' '--with-bz2' '--enable-ctype' '--with-db4' '--with-iconv' '--enable-exif' '--enable-filepro' '--enable-ftp' '--with-gettext' '--enable-mbstring' '--with-pcre-regex=/usr' '--enable-shmop' '--enable-sockets' '--enable-wddx' '--disable-xml' '--with-expat-dir=/usr' '--with-xmlrpc' '--enable-yp' '--with-zlib' '--without-pgsql' '--with-kerberos=/usr' '--with-openssl=/usr' '--enable-dbx' '--with-mime-magic=/usr/share/misc/file/magic.mime' '--with-exec-dir=/usr/lib/php4/libexec' '--disable-static' '--with-curl=shared,/usr' '--with-dom=shared,/usr' '--with-dom-xslt=shared,/usr' '--with-dom-exslt=shared,/usr' '--with-zlib-dir=/usr' '--with-gd=shared,/usr' '--enable-gd-native-ttf' '--with-jpeg-dir=shared,/usr' '--with-xpm-dir=shared,/usr/X11R6' '--with-png-dir=shared,/usr' '--with-freetype-dir=shared,/usr' '--with-imap=shared,/usr' '--with-imap-ssl' '--with-ldap=shared,/usr' '--with-mcal=shared,/usr' '--with-mhash=shared,/usr' '--without-mm' '--with-mysql=shared,/usr' '--with-unixODBC=shared,/usr' '--with-recode=shared,/usr' '--enable-xslt=shared' '--with-xslt-sablot=shared,/usr' '--with-snmp=shared,/usr' '--with-sybase-ct=shared,/usr' '--with-ttf=shared,/usr' '--with-t1lib=shared,/usr'