دوستان من میخوام از کلاس paging آقای موحد تو ام ویسی که تو این پکیج آموزش داده شده استفاده کنم
لطفا راهنمائی کنید
به عنوان مثال برای نمایش اخبار
این کلاس مدل اخبارمه :
لطفا راهنمائی کنید
به عنوان مثال برای نمایش اخبار
این کلاس مدل اخبارمه :
<?php class news extends model { private $fields = null; public function __construct() { $this->fields = array( 'id'=>null, 'cat_id'=>null, 'owner_id'=>null, 'title'=>null, 'description'=>null, 'visit'=>null, 'like'=>null, 'dislike'=>null, 'picture'=>null, 'create_date'=>null, 'update_date'=>null, 'expire_date'=>null, 'status'=>null, ); } public function __Get($fieldName){ if(isset($this->fields[$fieldName])){ return $this->fields[$fieldName]; } } public function __SET($fieldName, $value){ if(array_key_exists($fieldName, $this->fields)){ return $this->fields[$fieldName] = $value; } } public static function findByPk($id){ $object = null; $resault = Dal::ArrayQuery("SELECT * FROM `news` WHERE(`id`={$id})"); if(count($resault) > 0){ $object = new news(); foreach($resault[0] as $fieldName => $value){ $object->fields[$fieldName] = $value; } } return $object; } public static function findByLatest(){ $array = array(); $curentDate = date("Y/m/d"); $data = Dal::ArrayQuery("SELECT * FROM `news` WHERE (`status` = '1') ORDER BY `id` DESC LIMIT 1 "); if(count($data) > 0){ foreach($data as $resault){ $object = new news(); foreach($resault as $fieldName => $value){ $object->$fieldName = $value.PHP_EOL; } $array[] = $object; } } return $array; } public static function findAll($catId=NULL){ $array = array(); $curentDate = date("Y/m/d"); $data = Dal::ArrayQuery("SELECT * FROM `news` WHERE (`status` = '1') ORDER BY `id` DESC "); if(count($data) > 0){ foreach($data as $resault){ $object = new news(); foreach($resault as $fieldName => $value){ $object->$fieldName = $value.PHP_EOL; } $array[] = $object; } } return $array; } public static function findByCategoryId($id){ $array = array(); $data = Dal::ArrayQuery("SELECT * FROM `news` WHERE(`cat_id` = {$id}) ORDER BY `id` DESC"); if(count($data) > 0){ foreach($data as $resault){ $object = new news(); foreach($resault as $fieldName => $value){ $object->$fieldName = $value; } $array[] = $object; } } return $array; } } ?>