zoukankan      html  css  js  c++  java
  • OneThink视图模型进行组合查询!文档组合文档详情

    测试方法:twoCate:

    public function twoCate(){
        $where = array(
            'category_id'=>43
        );
        $list = D('TwoView')->where($where)->select();
        p($list);    
    }

    模型:

    <?php
    namespace HomeModel;
    use ThinkModelViewModel;
    
    /**
     * 文档基础模型
     */
    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) "医院新闻三医院新闻三医院新闻详情"
      }
    }
  • 相关阅读:
    UNIX环境高级编程 第9章 进程关系
    UNIX环境高级编程 第8章 进程控制
    UNIX环境高级编程 第7章 进程环境
    最小截断[AHOI2009]
    切糕[HNOI2013]
    餐巾
    happiness[国家集训队2011(吴确)]
    奇怪的道路[JXOI2012]
    王者之剑
    抵制克苏恩[Lydsy2017年4月月赛]
  • 原文地址:https://www.cnblogs.com/e0yu/p/7355616.html
Copyright © 2011-2022 走看看