ID:               44151
 Updated by:       dav...@php.net
 Reported By:      uwendel at mysql dot com
 Status:           Open
 Bug Type:         PDO related
 Operating System: Linux
 PHP Version:      5.3CVS-2008-02-18 (CVS)
-Assigned To:      
+Assigned To:      davidc
 New Comment:

Could you please test with the latest CVS or snapshot please? I have
made a few changes related to that lately and I'm wondering if that
could have fixed it.

Thanks,


Previous Comments:
------------------------------------------------------------------------

[2008-02-18 16:51:11] uwendel at mysql dot com

Description:
------------
According to the manual, PDO::errorInfo() returns the error information
about the "last operation performed by this database handle",
http://www.php.net/manual/en/function.PDO-errorInfo.php

What is PDO supposed to return if you perform two operations of which
the first fails and the second works fine, like this:

[1] THIS IS NO VALID SQL, I HOPE
[2] CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10), grp
VARCHAR(10))

Should errorInfo() return the error information from [1] or will the
error information be cleared prior to running [2]. In the latter case,
the user is given an additional easy way to check if an operation has
failed or not. 

And the latter case (clear info before running [2]) is what I as the
desired behaviour.

Next question: which elements of the errorInfo() element shall be
reset? Currently it seems to me as if the SQLSTATE code is reset to
'00000' but some drivers (e.g. PDO/MySQL, PDO/SQLlite, maybe more) do
not reset their driver specific fields. Haven't checked if that's an
issue caused by code from ext/pdo or from ext/pdo_mydriver. 









Reproduce code:
---------------
--TEST--
PDO Common: PDO->errorInfo(), clear line after error
--SKIPIF--
<?php # vim:ft=php
if (!extension_loaded('pdo')) die('skip');
$dir = getenv('REDIR_TEST_DIR');
if (false == $dir) die('skip no driver');
require_once $dir . 'pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php
if (getenv('REDIR_TEST_DIR') === false)
putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
$db = PDOTest::factory('PDO', false);

$db = PDOTest::factory('PDO', false);
@$db->exec('THIS IS NO VALID SQL, I HOPE');
var_dump($db->errorInfo());
var_dump($db->errorCode());

$db->exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val
VARCHAR(10), grp VARCHAR(10))');
var_dump($db->errorInfo());
var_dump($db->errorCode());
print "done!";
?>
--EXPECTF--
array(3) {
  [0]=>
  string(5) "%s"
  [1]=>
  int(%d)
  [2]=>
  string(%d) "%s"
}
string(5) "%s"
array(3) {
  [0]=>
  string(5) "00000"
  [1]=>
  NULL
  [2]=>
  NULL
}
string(5) "00000"
done!

Expected result:
----------------
see above

Actual result:
--------------
see above


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44151&edit=1

Reply via email to