openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit dfa665c361deeffcb22ef68ea4d635657b500d76
parent 529cfc90b8d95cca912275e324c89859d677ba44
Author: dankert <devnull@localhost>
Date:   Mon, 18 Jan 2010 21:18:24 +0100

Nur kleine Optimierungen

Diffstat:
Mdb/postgresql.class.php | 47+++++++++++++++++++++++++++++------------------
1 file changed, 29 insertions(+), 18 deletions(-)

diff --git a/db/postgresql.class.php b/db/postgresql.class.php @@ -42,7 +42,7 @@ class DB_postgresql * Verbinden zum POSTGRES-Server. * * @param Array $conf - * @return boolean + * @return boolean 'true', wenn Verbindung aufgebaut wurde */ function connect( $conf ) { @@ -70,7 +70,7 @@ class DB_postgresql if ( ! is_resource($this->connection) ) { - $this->error = 'could not connect to database on host '.$host; + $this->error = 'Could not connect to postgresql-server '.$host.': '.@pg_errormessage(); return false; } @@ -80,7 +80,7 @@ class DB_postgresql /** - * Verbindung schlie�en. + * Verbindung schliessen. * * @return unknown */ @@ -125,6 +125,7 @@ class DB_postgresql { if ( $this->prepared ) { + // Prepared Statement $ar = array(); foreach($this->params as $name => $data) { @@ -149,25 +150,26 @@ class DB_postgresql if ( $result === false ) { if ( empty($this->error) ) - $this->error = 'PostgreSQL (prepared) says: '.@pg_errormessage(); + $this->error = 'PostgreSQL is unable to execute the prepared statement: '.@pg_errormessage(); return FALSE; } return $result; } - - - - $result = @pg_exec( $this->connection,$query ); - - if ( ! $result ) - { - if ( empty($this->error) ) - $this->error = 'PostgreSQL (not prepared) says: '.@pg_errormessage(); - return FALSE; + else + { + // Flat Query: + $result = @pg_exec( $this->connection,$query ); + + if ( ! $result ) + { + if ( empty($this->error) ) + $this->error = 'PostgreSQL is unable to execute the flat query: '.@pg_errormessage(); + return FALSE; + } + + return $result; } - - return $result; } @@ -208,7 +210,6 @@ class DB_postgresql } $nr++; } - //Html::debug($query); $this->stmtid = md5($query); $this->prepared = true; @@ -217,7 +218,17 @@ class DB_postgresql if (pg_num_rows($result) > 0) return; - pg_prepare($this->connection,$this->stmtid,$query); + $erg = @pg_prepare($this->connection,$this->stmtid,$query); + + if ( $erg === FALSE ) + { + $this->error = 'PostgreSQL is unable to prepare the statement: '.@pg_errormessage(); + return FALSE; + } + else + { + return $erg; + } }