note 52341 deleted from function.mssql-query by nlopess

From: Date: Sun, 01 May 2005 08:16:02 +0000
Subject: note 52341 deleted from function.mssql-query by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-88818@lists.php.net to get a copy of this message
Note Submitter: vgr at europeanexperts dot org ---- The above is not (completely) true about the returned value. I have the example of a perfectly working query (tested in isql and other SQL-Server interfaces) returning no rows and no error messages at all, BUT mssql_query() returns FALSE with the "error message" (obtained from mssql_get_last_message() ) being "Changed database context to..." That query is very simple and does usually return very few rows, if any. Adding the "context" - full tablename qualifier, like "database501.dbo." - does NOT solve the issue. I had to code something like this //VGR28042005 FIXed problem with SQL-Server sending "Changed database context" and mssql_query returning FALSE !!! $z=@mssql_query($Query_String,$this->Link_ID); if ($z===FALSE) { $theerror=mssql_get_last_message(); // last one returned if (substr($theerror,0,24)=='Changed database context') $z=0; } //EoFix $this->result=$z; if ($z!==FALSE) { // ok $this->row=0; $this->record_count=($z==0)?0:mssql_num_rows($this->result); //VGR28042005 FIX return TRUE; } else { $this->Error=$theerror; return FALSE; } // EoAdd in stead of the - classical - if (($this->result=@mssql_query($Query_String,$this->Link_ID))!==FALSE) { // ok $this->row=0; $this->record_count=mssql_num_rows($this->result); return TRUE; } else { // ko $theerror=mssql_get_last_message(); // last one returned return FALSE; } Playing with error message levels and error levels didn't help neither. I precise that I'm using FreeTDS on *nix and haven't tested if this also happens on Windows with the ntwdblib.dll in stead. Hope This Helps someone someday ;-) ----------------------------- www.europeanexperts.org

« previous php.notes (#88818) next »