Phpcms v9 inside the Listinfo function is very good, unfortunately AH. Multiple table queries are not supported and paged.
Look at it. The foreground template layer supports get tags, supports multiple table queries, and supports paging. This function can be moved to the backstage to use.
We are now transforming the get_model.class.php so that he can support multiple table queries and pagination.
<?PHPdefined(' In_phpcms ') orExit(' No permission resources. '));p c_base:: Load_sys_class (' model ', ', 0);classGet_modelextendsModel { Public $db _config,$db _setting; Public function__construct ($db _config=Array(),$db _setting= ' ') { if(!$db _config) { $this->db_config = pc_base::load_config (' database '); } Else { $this->db_config =$db _config; } if(!$db _setting) { $this->db_setting = ' Default '; } Else { $this->db_setting =$db _setting; } Parent::__construct (); if($db _setting&&$db _config[$db _setting[' Db_tablepre ']) { $this->db_tablepre =$db _config[$db _setting[' Db_tablepre ']; } } Public functionSql_query ($sql) { if(!Empty($this->db_tablepre))$sql=Str_replace(' Phpcms_ ',$this->db_tablepre,$sql); returnParent::query ($sql); } Public functionFetch_next () {return $this->db->Fetch_next (); } //Custom Paging Query {supports multiple tables} Public functionMylistinfo ($where= ",$page= 1,$pagesize= 20,$key= ",$setpages= 10,$urlrule= ",$array=Array()) { $sql=Preg_replace('/select ([^from].*) from/i ', "SELECT count (*) as COUNT from",$where); $this->sql_query ($sql); $c=$this-Fetch_next (); $this- Number=$c[' Count ']; $page=Max(intval($page), 1); $offset=$pagesize*($page-1); $this->pages = Pages ($this- Number,$page,$pagesize,$urlrule,$array,$setpages); $r=$this->sql_query ($where.‘ LIMIT '.$offset.‘,‘.$pagesize); while(($s=$this->fetch_next ())! =false){ $data[] =$s; } return $data; }}?>
How to use:
$this->get_db = Pc_base::load_model (' Get_model '); $page intval ($_get[' page ']); $infos $this->get_db->mylistinfo ($where,$page); $pages $this->get_db->pages;
Http://www.chanyinkeji.com/phpcms-jiaocheng/10.html
PHPCMS v9 Background Multi-table query paging code