openrat-cms

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

commit 0edf39b7c0405ff781ed2fd3cf7400dae254eb85
parent 4cf587e2314b686deda240c9d0679f242046bf3c
Author: dankert <devnull@localhost>
Date:   Sat, 16 Jan 2010 00:29:03 +0100

Konfigurations-Schalter für PDO, um Spalten-Namen im Result in Kleinbuchstaben umzuändern (für Oracle)

Diffstat:
db/pdo.class.php | 21+++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/db/pdo.class.php b/db/pdo.class.php @@ -41,6 +41,8 @@ class DB_pdo * @var String */ var $error; + + var $lowercase = false; function connect( $conf ) @@ -49,6 +51,9 @@ class DB_pdo $user = $conf['user' ]; $pw = $conf['password']; + if ( $conf['convert_to_lowercase'] ) + $this->lowercase = true; + $options = array(); foreach( $conf as $c ) if ( substr($c,0,7) == 'option_' ) @@ -77,21 +82,25 @@ class DB_pdo function query($query) { - $this->result = $this->connection->query($query); - - if ( ! $this->result ) + $result = $this->connection->query($query); + + if ( ! $result ) { $this->error = 'Database error: '.PDO::errorInfo(); return FALSE; } - - return $this->result; + return $result; } function fetchRow( $result, $rownum ) { - return $this->result->fetch( PDO::FETCH_ASSOC ); + $row = $result->fetch( PDO::FETCH_ASSOC ); + + if ( is_array($row) && $this->lowercase ) + $row = array_change_key_case($row); + + return $row; }