php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #30807 mssql_query() return true on sql which return empty dataset
Submitted: 2004-11-16 16:53 UTC Modified: 2004-11-17 21:09 UTC
From: shagren at ua dot fm Assigned: fmk (profile)
Status: Closed Package: Documentation problem
PHP Version: 4.3.9 OS: Debian GNU Linux
Private report: No CVE-ID: None
 [2004-11-16 16:53 UTC] shagren at ua dot fm
Description:
------------
When i run query that return "no records" mssql_query return not "positive MS SQL result identifier". It return true.

I try this on Debian(current sarge version) with all package  with standard packagers version.

package: php4_4.3.9-1
Some info:

'../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'


freetds version 0.61



This bug like as http://bugs.php.net/bug.php?id=24720

Reproduce code:
---------------
<?php
$dbh=mssql_pconnect('mssqlserver.com', 'user', 'password');
echo "connect :" . mssql_get_last_message ()."\n";
mssql_select_db("shagren_temp", $dbh);
echo "select_db :" . mssql_get_last_message ()."\n";
$sth=mssql_query("select * from big where 1=2", $dbh);
echo "select :" . mssql_get_last_message ()."\n";
var_dump($sth);
$data=mssql_fetch_row($sth);
echo "fetch :" . mssql_get_last_message ()."\n";
?>


Expected result:
----------------
connect :Changed database context to 'master'.
select_db :Changed database context to 'shagren_temp'.
select :Changed database context to 'shagren_temp'.
<Some MSSQL ID>
fetch :Changed database context to 'shagren_temp'.


Actual result:
--------------
connect :Changed database context to 'master'.
select_db :Changed database context to 'shagren_temp'.

select :Changed database context to 'shagren_temp'.
bool(true)

Warning: mssql_fetch_row(): supplied argument is not a valid Sybase result resource in /root/tmp/mssql.php on line 9
fetch :Changed database context to 'shagren_temp'.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-16 16:58 UTC] shagren at ua dot fm
Must be: mssql_query() return true on empty dataset
 [2004-11-16 16:59 UTC] shagren at ua dot fm
Change topic more
 [2004-11-16 18:14 UTC] tony2001@php.net
Looks like documentation problem to me.
According to sources, this is the very expected behavior, as there is no sense in fetching result that contains no data. 
Reclassifying.
 [2004-11-16 18:59 UTC] fmk@php.net
This is not MSSQL related. You are compiling using --with-sybase-ct. If you change that to --with-mssql you'll get the expected result. (Tested with current CVS for 4.3.10).
 [2004-11-17 10:41 UTC] shagren at ua dot fm
>This is not MSSQL related.
Hm... I have problem with mssql_query() function and this is not MSSQL related?
 [2004-11-17 21:09 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"Returns: A positive MS SQL result identifier on success, true if no rows were returned, or false on error."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 20 20:00:03 2025 UTC