码迷,mamicode.com
首页 > 其他好文 > 详细

4--视图模型

时间:2015-05-19 12:34:58      阅读:97      评论:0      收藏:0      [点我收藏+]

标签:

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 ?>

 

4--视图模型

标签:

原文地址:http://www.cnblogs.com/freestyle-le/p/4514029.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!