php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39053 errorInfo not populated for connect error
Submitted: 2006-10-05 20:23 UTC Modified: 2006-10-09 16:28 UTC
From: xing at mac dot com Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5CVS-2006-10-05 (snap) OS: Linux
Private report: No CVE-ID: None
 [2006-10-05 20:23 UTC] xing at mac dot com
Description:
------------
When pdo connect fails, the pdoexception object field "errorInfo" is properly set.

Mysql 5.0.24a
PHP 5.2snap



Reproduce code:
---------------
Use pdo to a non-existing mysql server. Catch and print_r() exception.


Expected result:
----------------
...pdo exception snippet...

[errorInfo] => Array
        (
            [0] => HY000
            [1] => 2003
            [2] => Can't connect to MySQL server on '1276.0.0.86' (111)
        )

Actual result:
--------------
[errorInfo] => 

(empty errorInfo property)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-05 20:30 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2006-10-05 20:38 UTC] xing at mac dot com
<?php

try {
  $link = new PDO("mysql:host=127.0.0.1;port=99;","user","pass");
  $link->setAttribute (PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  $link->setAttribute (PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, TRUE);


  $link->query("SET NAMES 'utf8'");
  $link->query("show slave status");
  echo "good";
}
catch (PDOException $e) {
  echo "<pre>";
  print_r($e);
  echo "</pre>";
}
?>
 [2006-10-09 16:28 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Due to the fact connection has failed there is no context for 
the error.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 12:01:27 2024 UTC