Home » Database » DB » Bug #2011
UNABLE TO DETECT CONECTION ERROR WITH PGSQL
Details
| Submitted | 2004-07-29 02:29 UTC |
|---|---|
| From | abaqueiro at yahoo dot com |
| Assigned | danielc |
| Status | Closed |
| Package | DB |
| PHP Version | 5.0.0 |
| OS | Linux Redhat 9 |
| Roadmaps | (Not assigned) |
Comments
[2004-07-29 02:29 UTC] abaqueiro at yahoo dot com
Description:
------------
File : DB/pgsql.php
PEAR Version: All
UNABLE TO DETECT CONECTION ERROR WITH PGSQL
Probably is due to the way the error message is traped:
$connect_function = $persistent ? 'pg_pconnect' : 'pg_connect';
// catch error
ob_start();
$conn = $connect_function($connstr);
$error = ob_get_contents();
ob_end_clean();
if ($conn == false) {
return $this->raiseError(DB_ERROR_CONNECT_FAILED, null,
null, null, strip_tags($error));
}
$this->connection = $conn;
return DB_OK;
IT IS A REALLY A UGLY WAY TO DO IT, AND FOR SCRIPTS THAT ALREADY HAD OUTPUT SOMETHING, THAT OUTPUT IS LOST, AND FOR SOME OTHER REASONS ??? THE ERROR MESSAGE IS NOT TRAPED.
IN FACT IT CAN BE DONE IN A BETTER-CLEANER WAY:
$connect_function = $persistent ? 'pg_pconnect' : 'pg_connect';
// catch error
ini_set( 'track_errors', true );
$conn = $connect_function($connstr);
if ($conn === false) {
return $this->raiseError(DB_ERROR_CONNECT_FAILED, null,
null, null, $php_errormsg);
}
$this->connection = $conn;
return DB_OK;