ThinkPHP示例:视图模型

ThinkPHP示例之:视图模型

ThinkPHP的视图模型模拟了数据库的视图实现,可以方便地完成简单的数据关联操作。
注意看下面的数据列表中的类型名称就是通过视图模型来获取的。
{$vo.title} [ category:{$vo.category} time:{$vo.cTime|date='Y-m-d H:i:s',###} read:{$vo.readCount} | comment:{$vo.commentCount}]

示例源码
控制器IndexAction类
highlight_file(LIB_PATH.'Action/IndexAction.class.php');
模型Blog类
highlight_file(LIB_PATH.'Model/BlogModel.class.php');
模型Category类
highlight_file(LIB_PATH.'Model/CategoryModel.class.php');
视图模型BlogViewModel类
highlight_file(LIB_PATH.'Model/BlogViewModel.class.php');