#39564 [Opn->Bgs]: PDO::errorInfo() returns inconsistent information
| From: | tony2001@php.net | Date: | Tue, 21 Nov 2006 22:10:34 +0000 |
| Subject: | #39564 [Opn->Bgs]: PDO::errorInfo() returns inconsistent information | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-105271@lists.php.net to get a copy of this message | ||
ID: 39564
Updated by: tony2001@php.net
Reported By: php dot bugreport dot tarpit at spamgourmet dot com
-Status: Open
+Status: Bogus
Bug Type: PDO related
Operating System: Windows 98SE and XP/SP1
PHP Version: 5.2.0
New Comment:
These two methods use different SQLite functions to execute queries,
which report different errors. And that is the reason I can hardly
imagine why it's PDO fault.
Previous Comments:
------------------------------------------------------------------------
[2006-11-21 22:04:52] php dot bugreport dot tarpit at spamgourmet dot
com
Original category was "SQLite related" - because that is the only part
of PDO I use. Since the error is obviously not in SQLite (which reports
the correct errors), but in PDO (which reports different errors
depending on the use of PDO::exec() or PDOStatement::execute()
functions), category "PDO related" would be better.
------------------------------------------------------------------------
[2006-11-21 09:29:12] tony2001@php.net
SQLite inconsistencies should be reported to SQLite developers.
------------------------------------------------------------------------
[2006-11-20 23:56:21] php dot bugreport dot tarpit at spamgourmet dot
com
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 this bug report at http://bugs.php.net/?id=39564&edit=1