Browse Source

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
master
akulikov 16 years ago
parent
commit
3c08d0f902
  1. 2
      DBConnector.class.php
  2. 10
      Model.class.php

2
DBConnector.class.php

@ -31,7 +31,7 @@ class DBConnector
return self::$handlers[$handler_name]; 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); throw new MJException('Can\'t connect to DB '.mysqli_connect_error(), 2);
} }

10
Model.class.php

@ -137,12 +137,18 @@ class ModelSelectResult extends ModelResult
return isset($row->$field) ? $row->$field : $default; return isset($row->$field) ? $row->$field : $default;
} }
function fetchAll()
function fetchAll($key = false)
{ {
$array = array(); $array = array();
if ($key) {
while ($row = mysqli_fetch_object($this->result)) {
$array[$row->$key] = $row;
}
} else {
while ($row = mysqli_fetch_object($this->result)) { while ($row = mysqli_fetch_object($this->result)) {
$array[] = $row; $array[] = $row;
} }
}
return $array; return $array;
} }
@ -167,7 +173,7 @@ class ModelChangeResult extends ModelResult
function __construct($resource) function __construct($resource)
{ {
$this->affected = mysql_affected_rows($resource);
$this->affected = mysqli_affected_rows($resource);
} }
function count() function count()

Loading…
Cancel
Save