|
|
@ -19,7 +19,7 @@ abstract class Model |
|
|
|
|
|
|
|
function __construct() |
|
|
|
{ |
|
|
|
$this->handler = DBConnector::getInstance()->getConnect(Env::getParam('db_settings')); |
|
|
|
$this->handler = DBConnector::getConnect(Env::getParam('db_settings')); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -33,9 +33,9 @@ abstract class Model |
|
|
|
if (DEBUG_ENABLE) { |
|
|
|
$time = microtime(true); |
|
|
|
} |
|
|
|
$res = mysqli_query($this->handler, $sql); |
|
|
|
if (mysqli_errno($this->handler)) { |
|
|
|
throw new MJException("<b>Query Error:</b>\n".$sql."\n<b>Error:</b>\n".mysqli_error($this->handler), 1); |
|
|
|
$res = DBConnector::query($this->handler, $sql); |
|
|
|
if ($error = DBConnector::error($this->handler)) { |
|
|
|
throw new MJException("<b>Query Error:</b>\n".$sql."\n<b>Error:</b>\n".$error, 1); |
|
|
|
} |
|
|
|
|
|
|
|
if (DEBUG_ENABLE) { |
|
|
@ -77,11 +77,11 @@ abstract class Model |
|
|
|
{ |
|
|
|
if(is_array($data)){ |
|
|
|
foreach($data as $id => $val){ |
|
|
|
$data[$id] = mysqli_real_escape_string($this->handler, $val); |
|
|
|
$data[$id] = DBConnector::escape($this->handler, $val); |
|
|
|
} |
|
|
|
return $data; |
|
|
|
} |
|
|
|
return mysqli_real_escape_string($this->handler, $data); |
|
|
|
return DBConnector::escape($this->handler, $data); |
|
|
|
} |
|
|
|
|
|
|
|
//////////////////////////
|
|
|
@ -123,17 +123,17 @@ abstract class Model |
|
|
|
|
|
|
|
function setAutocommit($set) |
|
|
|
{ |
|
|
|
return mysqli_autocommit($this->handler, (bool) $set); |
|
|
|
return DBConnector::autocommit($this->handler, (bool) $set); |
|
|
|
} |
|
|
|
|
|
|
|
function commit() |
|
|
|
{ |
|
|
|
return mysqli_commit($this->handler); |
|
|
|
return DBConnector::commit($this->handler); |
|
|
|
} |
|
|
|
|
|
|
|
function rollback() |
|
|
|
{ |
|
|
|
return mysqli_rollback($this->handler); |
|
|
|
return DBConnector::rollback($this->handler); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -156,7 +156,7 @@ class ModelSelectResult extends ModelResult |
|
|
|
|
|
|
|
function fetch($class_name = false) |
|
|
|
{ |
|
|
|
return $class_name ? mysqli_fetch_object($this->result, $class_name) : mysqli_fetch_object($this->result); |
|
|
|
return DBConnector::fetchObject($this->result, $class_name); |
|
|
|
} |
|
|
|
|
|
|
|
function fetchField($field, $default = false) |
|
|
@ -169,11 +169,11 @@ class ModelSelectResult extends ModelResult |
|
|
|
{ |
|
|
|
$array = array(); |
|
|
|
if ($key) { |
|
|
|
while ($row = mysqli_fetch_object($this->result)) { |
|
|
|
while ($row = DBConnector::fetchObject($this->result)) { |
|
|
|
$array[$row->$key] = $row; |
|
|
|
} |
|
|
|
} else { |
|
|
|
while ($row = mysqli_fetch_object($this->result)) { |
|
|
|
while ($row = DBConnector::fetchObject($this->result)) { |
|
|
|
$array[] = $row; |
|
|
|
} |
|
|
|
} |
|
|
@ -182,12 +182,12 @@ class ModelSelectResult extends ModelResult |
|
|
|
|
|
|
|
function count() |
|
|
|
{ |
|
|
|
return mysqli_num_rows($this->result); |
|
|
|
return DBConnector::numRows($this->result); |
|
|
|
} |
|
|
|
|
|
|
|
function free() |
|
|
|
{ |
|
|
|
mysqli_free_result($this->result); |
|
|
|
DBConnector::free($this->result); |
|
|
|
} |
|
|
|
|
|
|
|
function __destruct() { |
|
|
@ -201,7 +201,7 @@ class ModelChangeResult extends ModelResult |
|
|
|
|
|
|
|
function __construct($resource) |
|
|
|
{ |
|
|
|
$this->affected = mysqli_affected_rows($resource); |
|
|
|
$this->affected = DBConnector::affectedRows($resource); |
|
|
|
} |
|
|
|
|
|
|
|
function count() |
|
|
@ -217,7 +217,7 @@ class ModelInsertResult extends ModelChangeResult |
|
|
|
function __construct($resource) |
|
|
|
{ |
|
|
|
parent::__construct($resource); |
|
|
|
$this->id = mysqli_insert_id($resource); |
|
|
|
$this->id = DBConnector::getId($resource); |
|
|
|
} |
|
|
|
|
|
|
|
function getId() |
|
|
|