From 74ce05ebc0b899cf435b1b2c44b8d5cf37d17ef1 Mon Sep 17 00:00:00 2001 From: akulikov Date: Wed, 6 May 2009 12:28:25 +0000 Subject: [PATCH] postgre fix git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@87 4cb57b5f-5bbd-dd11-951b-001d605cbbc5 --- classes/DBConnector.class.php | 2 +- classes/Model.class.php | 12 ++++++------ classes/pg_DBConnector.class.php | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/classes/DBConnector.class.php b/classes/DBConnector.class.php index 826283b..2e1b443 100644 --- a/classes/DBConnector.class.php +++ b/classes/DBConnector.class.php @@ -131,7 +131,7 @@ class DBConnector return mysqli_num_rows($result); } - static public function affectedRows($handler) + static public function affectedRows($handler, $result) { return mysqli_affected_rows($handler); } diff --git a/classes/Model.class.php b/classes/Model.class.php index e707e48..f331829 100644 --- a/classes/Model.class.php +++ b/classes/Model.class.php @@ -61,9 +61,9 @@ abstract class Model return new ModelSelectResult($res); case 'insert': case 'replac': - return new ModelInsertResult($this->handler); + return new ModelInsertResult($this->handler, $res); //$res for postgreSQL default: - return new ModelChangeResult($this->handler); + return new ModelChangeResult($this->handler, $res); //$res for postgreSQL } } @@ -224,9 +224,9 @@ class ModelChangeResult extends ModelResult { public $affected; - function __construct($resource) + function __construct($resource, $result) { - $this->affected = DBConnector::affectedRows($resource); + $this->affected = DBConnector::affectedRows($resource, $result); } function count() @@ -239,9 +239,9 @@ class ModelInsertResult extends ModelChangeResult { public $id; - function __construct($resource) + function __construct($resource, $result) { - parent::__construct($resource); + parent::__construct($resource, $result); $this->id = DBConnector::getId($resource); } diff --git a/classes/pg_DBConnector.class.php b/classes/pg_DBConnector.class.php index c70e52e..68335f1 100644 --- a/classes/pg_DBConnector.class.php +++ b/classes/pg_DBConnector.class.php @@ -38,10 +38,10 @@ class DBConnector return self::$handlers[$handler_name]; } - if (!$handler = pg_connect("host='".$db_settings['host']."' dbname='".$db_settings['database']."' user='".$db_settings['user'].'" password="'.$db_settings['password']."'")) { - throw new MJException('Can\'t connect to DB '.pg_last_error($handler), 2); + if (!$handler = pg_connect("host='".$db_settings['host']."' dbname='".$db_settings['database']."' user='".$db_settings['user']."' password='".$db_settings['password']."'")) { + throw new MJException('Can\'t connect to DB '.pg_last_error(), 2); } - + return self::$handlers[$handler_name] = $handler; } @@ -82,9 +82,9 @@ class DBConnector return pg_num_rows($result); } - static public function affectedRows($handler) + static public function affectedRows($handler, $result) { - return pg_affected_rows($handler); + return pg_affected_rows($result); } static public function getId($handler)