Commit 04cd1ab1 authored by Alexander Butenko's avatar Alexander Butenko Committed by GitHub

Merge pull request #569 from Tom29/master

Fixed byId and provide pagination with data type
parents 0595c669 4924058a
...@@ -299,7 +299,7 @@ class dbObject { ...@@ -299,7 +299,7 @@ class dbObject {
* *
* @return dbObject|array * @return dbObject|array
*/ */
protected function byId ($id, $fields = null) { private function byId ($id, $fields = null) {
$this->db->where (MysqliDb::$prefix . $this->dbTable . '.' . $this->primaryKey, $id); $this->db->where (MysqliDb::$prefix . $this->dbTable . '.' . $this->primaryKey, $id);
return $this->getOne ($fields); return $this->getOne ($fields);
} }
...@@ -438,6 +438,25 @@ class dbObject { ...@@ -438,6 +438,25 @@ class dbObject {
$this->db->pageLimit = self::$pageLimit; $this->db->pageLimit = self::$pageLimit;
$res = $this->db->paginate ($this->dbTable, $page, $fields); $res = $this->db->paginate ($this->dbTable, $page, $fields);
self::$totalPages = $this->db->totalPages; self::$totalPages = $this->db->totalPages;
if ($this->db->count == 0) return null;
foreach ($res as &$r) {
$this->processArrays ($r);
$this->data = $r;
$this->processAllWith ($r, false);
if ($this->returnType == 'Object') {
$item = new static ($r);
$item->isNew = false;
$objects[] = $item;
}
}
$this->_with = Array();
if ($this->returnType == 'Object')
return $objects;
if ($this->returnType == 'Json')
return json_encode ($res);
return $res; return $res;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment