From 3c08d0f9021bef67710b8a049a54eb3f5e02a7fc Mon Sep 17 00:00:00 2001 From: akulikov Date: Wed, 3 Dec 2008 11:22:33 +0000 Subject: [PATCH] Error ignore removed And fetchAll method enchanted (now with key) git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@11 4cb57b5f-5bbd-dd11-951b-001d605cbbc5 --- DBConnector.class.php | 2 +- Model.class.php | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/DBConnector.class.php b/DBConnector.class.php index f63314c..084e660 100644 --- a/DBConnector.class.php +++ b/DBConnector.class.php @@ -31,7 +31,7 @@ class DBConnector return self::$handlers[$handler_name]; } - if (!$handler = @mysqli_connect($db_settings['host'], $db_settings['user'], $db_settings['password'], $db_settings['database'])) { + if (!$handler = mysqli_connect($db_settings['host'], $db_settings['user'], $db_settings['password'], $db_settings['database'])) { throw new MJException('Can\'t connect to DB '.mysqli_connect_error(), 2); } diff --git a/Model.class.php b/Model.class.php index e9e74a8..1dc8223 100644 --- a/Model.class.php +++ b/Model.class.php @@ -137,11 +137,17 @@ class ModelSelectResult extends ModelResult return isset($row->$field) ? $row->$field : $default; } - function fetchAll() + function fetchAll($key = false) { $array = array(); - while ($row = mysqli_fetch_object($this->result)) { - $array[] = $row; + if ($key) { + while ($row = mysqli_fetch_object($this->result)) { + $array[$row->$key] = $row; + } + } else { + while ($row = mysqli_fetch_object($this->result)) { + $array[] = $row; + } } return $array; } @@ -167,7 +173,7 @@ class ModelChangeResult extends ModelResult function __construct($resource) { - $this->affected = mysql_affected_rows($resource); + $this->affected = mysqli_affected_rows($resource); } function count()