OneThink視圖模型進行組合查詢!文檔組合文檔詳情
阿新 • • 發佈:2017-08-14
lds str esp 詳情 logs spa sel ring date_time
測試方法: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) "醫院新聞三醫院新聞三醫院新聞詳情" } }
OneThink視圖模型進行組合查詢!文檔組合文檔詳情