note 66413 added to ref.pdo
| From: | nicolas at serpe dot org | Date: | Sun, 21 May 2006 19:36:29 +0000 |
| Subject: | note 66413 added to ref.pdo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-111790@lists.php.net to get a copy of this message | ||
I use PDO with the ODBC driver to query stored procedures in a MS SQL Server 2005 Database under
Windows XP Professional with IIS 5 and PHP 5.1.4. You may have the same problems with a different
configuration.
I experienced 2 very time consuming errors:
1. The first one is when you return the result of a SELECT query, and you get the following clueless
message:
>>> Fatal error: Uncaught exception 'PDOException' with message
>>> 'SQLSTATE[24000]: Invalid cursor state: 0 [Microsoft][SQL Native Client]Invalid cursor state
>>> (SQLFetchScroll[0] at ext\pdo_odbc\odbc_stmt.c:372)' in (YOUR_TRACE_HERE) <<<
Your exact message may be different, the part to pay attention to is "Invalid cursor
state".
-> I found that I had this error because I didn't include "SET NOCOUNT ON" in the
*body* of the stored procedure. By default the server returns a special piece of information along
with the results, indicating how many rows were affected by the stored procedure, and that's
not handled by PDO.
2. The second error I had was:
>>> Fatal error: Uncaught exception 'PDOException' with message
>>> 'SQLSTATE[22003]: Numeric value out of range: 0 [Microsoft][SQL Native Client]Numeric value out
>>> of range (SQLFetchScroll[0] at ext\pdo_odbc\odbc_stmt.c:372)' in (YOUR_TRACE_HERE) <<<
Another meaningless error "Numeric value out of range"...
-> I was actually returning a date datatype (datetime or smalldatetime) "as is", that
is, without converting it to varchar before including it in the result set... I don't know if
PDO is responsible for converting it to a PHP datatype, but it doesn't. Convert it before it
reaches PHP.
----
Server IP: 195.221.21.36
Probable Submitter: 82.241.202.105
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/ref.pdo.php
Edit -- http://master.php.net/note/edit/66413
Del: integrated -- http://master.php.net/note/delete/66413/integrated
Del: useless -- http://master.php.net/note/delete/66413/useless
Del: bad code -- http://master.php.net/note/delete/66413/bad+code
Del: spam -- http://master.php.net/note/delete/66413/spam
Del: non-english -- http://master.php.net/note/delete/66413/non-english
Del: in docs -- http://master.php.net/note/delete/66413/in+docs
Del: other reasons-- http://master.php.net/note/delete/66413
Reject -- http://master.php.net/note/reject/66413
Search -- http://master.php.net/manage/user-notes.php