标签:
1、创建视图
1 <?php 2 class CategoryViewModel extends ViewModel{ 3 public $viewFields=array( 4 //SELECT Category.id AS cid,Category.title AS ctitle,Category.alias AS calias,Category.published AS cpublished, 5 // Category.order AS corder,Category.access AS caccess,Category.sectionid AS sectionid, 6 // Section.title AS sec_Name 7 // FROM joys_category Category JOIN joys_section Section 8 // ON Category.sectionid=Section.id 9 ‘Category‘=>array(‘id‘=>‘cid‘,‘title‘=>‘ctitle‘,‘alias‘=>‘calias‘,‘published‘=>‘cpublished‘,‘order‘=>‘corder‘,‘access‘=>‘caccess‘,‘sectionid‘), 10 ‘Section‘=>array(‘title‘=>‘sec_Name‘,‘_on‘=>‘Category.sectionid=Section.id‘), 11 12 ); 13 } 14 ?>
2、测试
1 <?php 2 class CategoryAction extends CommonAction{ 3 public function index(){ 4 $sec=new CategoryViewModel(); 5 dump($sec->select()); 6 $this->display(); 7 } 8 public function add(){} 9 public function edit(){} 10 public function delete(){} 11 public function update(){} 12 13 14 } 15 16 17 18 19 20 21 ?>
标签:
原文地址:http://www.cnblogs.com/freestyle-le/p/4514029.html