4--视图模型
原文:4--視圖模型
1、創(chuàng)建視圖
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 ?>?
總結(jié)
- 上一篇: wine on ubuntu linux
- 下一篇: SQLite3-各个函数