#39564 [NEW]: PDO::errorInfo() returns inconsistent information
| From: | php dot bugreport dot tarpit at spamgourmet dot com | Date: | Mon, 20 Nov 2006 23:56:21 +0000 |
| Subject: | #39564 [NEW]: PDO::errorInfo() returns inconsistent information | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-105228@lists.php.net to get a copy of this message | ||
From: php dot bugreport dot tarpit at spamgourmet dot com
Operating system: Windows 98SE and XP/SP1
PHP version: 5.2.0
PHP Bug Type: SQLite related
Bug description: PDO::errorInfo() returns inconsistent information
Description:
------------
When retrieving error information with PDO::errorInfo() after an
SQL-insert causing a constraint violation results are inconsistent
depending on the form of the statement: PDO::exec() or
PDOStatement::execute().
Reproduce code:
---------------
SQL to create database followed by sample PHP:
CREATE TABLE TEST ( Key Integer Primary Key, Text Char(20) Not Null );
CREATE UNIQUE INDEX iTEST On TEST ( Text );
<?php
$dbh_test=New PDO("sqlite:C:/Data/PHP5TEST.DB");
$dbh_test->SetAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$dbh_test->Exec("Insert Into TEST (Key, Text) Values (1, 'Test1')");
$pdo_error=$dbh_test->ErrorInfo();
Print "\n$pdo_error[0] $pdo_error[1] $pdo_error[2] :: 1, 'Test1'\n";
$sql="Insert Into TEST (Key, Text) Values (:key, :text)";
$sq_insert=$dbh_test->Prepare($sql);
$sq_insert->BindParam(':key', $key); $sq_insert->BindParam(':text',
$text);
$key=1; $text="Test1"; $sq_insert->Execute();
$pdo_error=$sq_insert->ErrorInfo();
Print "\n$pdo_error[0] $pdo_error[1] $pdo_error[2] :: $key, $text\n";
Exit(0);
?>
Expected result:
----------------
23000 19 PRIMARY KEY must be unique :: 1, 'Test1'
23000 19 PRIMARY KEY must be unique :: 1, 'Test1'
Actual result:
--------------
PHP 5.1.6:
23000 19 PRIMARY KEY must be unique :: 1, 'Test1'
HY000 1 PRIMARY KEY must be unique :: 1, Test1
PHP 5.2.0:
23000 19 PRIMARY KEY must be unique :: 1, 'Test1'
HY000 1 SQL logic error or missing database :: 1, Test1
5CVS-2006-11-18:
23000 19 PRIMARY KEY must be unique :: 1, 'Test1'
HY000 1 SQL logic error or missing database :: 1, Test1
--
Edit bug report at http://bugs.php.net/?id=39564&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39564&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39564&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39564&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39564&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=39564&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39564&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39564&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39564&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39564&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39564&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=39564&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=39564&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39564&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39564&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39564&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39564&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39564&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39564&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39564&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39564&r=mysqlcfg