From: Greg Sabino Mullane Date: Tue, 27 Jun 2006 00:53:46 +0000 (+0000) Subject: Fix last_error for connection case, change Database to __construct X-Git-Tag: 1.31.0-rc.0~56581 X-Git-Url: http://git.cyclocoop.org/clavettes/images/siteon3.jpg?a=commitdiff_plain;h=72f308435386adf891265dcef6f8b3fd233697a8;p=lhc%2Fweb%2Fwiklou.git Fix last_error for connection case, change Database to __construct --- diff --git a/includes/DatabasePostgres.php b/includes/DatabasePostgres.php index 7659473759..e904949aab 100644 --- a/includes/DatabasePostgres.php +++ b/includes/DatabasePostgres.php @@ -27,15 +27,15 @@ class DatabasePostgres extends Database { var $mLastResult = NULL; function DatabasePostgres($server = false, $user = false, $password = false, $dbName = false, - $failFunction = false, $flags = 0, $tablePrefix = 'get from global' ) + $failFunction = false, $flags = 0 ) { - Database::Database( $server, $user, $password, $dbName, $failFunction, $flags, $tablePrefix ); + Database::__construct( $server, $user, $password, $dbName, $failFunction, $flags ); } - /* static */ function newFromParams( $server = false, $user = false, $password = false, $dbName = false, - $failFunction = false, $flags = 0, $tablePrefix = 'get from global' ) + static function newFromParams( $server = false, $user = false, $password = false, $dbName = false, + $failFunction = false, $flags = 0) { - return new DatabasePostgres( $server, $user, $password, $dbName, $failFunction, $flags, $tablePrefix ); + return new DatabasePostgres( $server, $user, $password, $dbName, $failFunction, $flags ); } /** @@ -65,6 +65,7 @@ class DatabasePostgres extends Database { if ($server!=false && $server!="") { $hstring="host=$server "; } + @$this->mConn = pg_connect("$hstring dbname=$dbName user=$user password=$password"); if ( $this->mConn == false ) { wfDebug( "DB connection error\n" ); @@ -144,7 +145,14 @@ class DatabasePostgres extends Database { } function dataSeek( $res, $row ) { return pg_result_seek( $res, $row ); } - function lastError() { return pg_last_error(); } + function lastError() { + if ( $this->mConn ) { + return pg_last_error(); + } + else { + return "No database connection"; + } + } function lastErrno() { return 1; } function affectedRows() {