@@ -261,7 +261,7 @@ public function update ($data = null) {
261261 $ sqlData = $ this ->prepareData ();
262262 if (!$ this ->validate ($ sqlData ))
263263 return false ;
264-
264+
265265 $ this ->db ->where ($ this ->primaryKey , $ this ->data [$ this ->primaryKey ]);
266266 return $ this ->db ->update ($ this ->dbTable , $ sqlData );
267267 }
@@ -299,7 +299,7 @@ public function delete () {
299299 *
300300 * @return dbObject|array
301301 */
302- protected function byId ($ id , $ fields = null ) {
302+ private function byId ($ id , $ fields = null ) {
303303 $ this ->db ->where (MysqliDb::$ prefix . $ this ->dbTable . '. ' . $ this ->primaryKey , $ id );
304304 return $ this ->getOne ($ fields );
305305 }
@@ -438,6 +438,25 @@ private function paginate ($page, $fields = null) {
438438 $ this ->db ->pageLimit = self ::$ pageLimit ;
439439 $ res = $ this ->db ->paginate ($ this ->dbTable , $ page , $ fields );
440440 self ::$ totalPages = $ this ->db ->totalPages ;
441+ if ($ this ->db ->count == 0 ) return null ;
442+
443+ foreach ($ res as &$ r ) {
444+ $ this ->processArrays ($ r );
445+ $ this ->data = $ r ;
446+ $ this ->processAllWith ($ r , false );
447+ if ($ this ->returnType == 'Object ' ) {
448+ $ item = new static ($ r );
449+ $ item ->isNew = false ;
450+ $ objects [] = $ item ;
451+ }
452+ }
453+ $ this ->_with = Array ();
454+ if ($ this ->returnType == 'Object ' )
455+ return $ objects ;
456+
457+ if ($ this ->returnType == 'Json ' )
458+ return json_encode ($ res );
459+
441460 return $ res ;
442461 }
443462
0 commit comments