测试方法:twoCate:
public function twoCate(){ $where = array( ‘category_id‘=>43 ); $list = D(‘TwoView‘)->where($where)->select(); p($list); }
模型:
<?php namespace Home\Model; use Think\Model\ViewModel; /** * 文档基础模型 */ class TwoViewModel extends ViewModel{ public $viewFields = array( ‘document‘ => array( ‘id‘,‘uid‘,‘name‘,‘title‘,‘update_time‘, ‘_type‘ => ‘LEFT‘ ), ‘document_article‘ => array( ‘content‘, ‘_on‘ => ‘document.id = document_article.id‘ ) ); }
组合后的列表:
array(3) { [0]=> array(6) { ["id"]=> string(1) "7" ["uid"]=> string(1) "1" ["name"]=> string(0) "" ["title"]=> string(15) "医院新闻一" ["update_time"]=> string(10) "1502544150" ["content"]=> string(750) "医院新闻一医院新闻一医院新闻详情" } [1]=> array(6) { ["id"]=> string(1) "8" ["uid"]=> string(1) "1" ["name"]=> string(0) "" ["title"]=> string(15) "医院新闻二" ["update_time"]=> string(10) "1502544139" ["content"]=> string(195) "医院新闻二医院新闻二医院新闻详情" } [2]=> array(6) { ["id"]=> string(1) "9" ["uid"]=> string(1) "1" ["name"]=> string(0) "" ["title"]=> string(15) "医院新闻三" ["update_time"]=> string(10) "1502544159" ["content"]=> string(735) "医院新闻三医院新闻三医院新闻详情" } }
时间: 2024-10-21 11:25:59