Edit report at http://bugs.php.net/bug.php?id=51742&edit=1
ID: 51742
Comment by: bandy dot chris at gmail dot com
Reported by: mike at mikegerwitz dot com
Summary: A non well formed numeric value encountered
Status: Open
Type: Bug
Package: PDO related
Operating System: All
PHP Version: 5.3.2
Block user comment: N
Private report: N
New Comment:
Related to bug 39615.
Previous Comments:
------------------------------------------------------------------------
[2010-09-17 13:46:13] mpartio at gmail dot com
I agree to Mike: PHP should allow non-numeric exception codes. I think
this should be pretty easy to fix?
------------------------------------------------------------------------
[2010-05-04 21:29:57] mike at mikegerwitz dot com
Description:
------------
PDOException extends RuntimeException which in turn extends Exception.
The
Exception class has the following constructor:
public __construct ([ string $message = "" [, int $code = 0 [, Exception
$previous = NULL ]]] )
The $code parameter is to be of type integer. However, when using
pdo_odbc or
pdo_dblib, the error code returned by the server may be a string, rather
than an
integer. So, for example, calling $e->getCode() may yield a value of
"12X34".
This is inconsistent with the method definition as well:
final public int getCode ( void )
PHP's own internal library should not produce outcomes that are in
conflict with
PHP's definitions.
Test script:
---------------
try
{
$pdo->query( 'BAD QUERY' );
}
catch ( PDOException $e )
{
throw new Exception( $e->getMessage(), $e->getCode() );
}
Expected result:
----------------
// Just a thrown exception, nothing important
Actual result:
--------------
PHP Notice: A non well formed numeric value encountered in [...] on
line 7
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51742&edit=1