• <tfoot id='PxXYz'></tfoot>

  • <i id='PxXYz'><tr id='PxXYz'><dt id='PxXYz'><q id='PxXYz'><span id='PxXYz'><b id='PxXYz'><form id='PxXYz'><ins id='PxXYz'></ins><ul id='PxXYz'></ul><sub id='PxXYz'></sub></form><legend id='PxXYz'></legend><bdo id='PxXYz'><pre id='PxXYz'><center id='PxXYz'></center></pre></bdo></b><th id='PxXYz'></th></span></q></dt></tr></i><div id='PxXYz'><tfoot id='PxXYz'></tfoot><dl id='PxXYz'><fieldset id='PxXYz'></fieldset></dl></div>

    <small id='PxXYz'></small><noframes id='PxXYz'>

    <legend id='PxXYz'><style id='PxXYz'><dir id='PxXYz'><q id='PxXYz'></q></dir></style></legend>

        • <bdo id='PxXYz'></bdo><ul id='PxXYz'></ul>
      1. Yii CDbCriteria 加入

        时间:2023-09-24

          <small id='5JGv0'></small><noframes id='5JGv0'>

            • <tfoot id='5JGv0'></tfoot>
              <i id='5JGv0'><tr id='5JGv0'><dt id='5JGv0'><q id='5JGv0'><span id='5JGv0'><b id='5JGv0'><form id='5JGv0'><ins id='5JGv0'></ins><ul id='5JGv0'></ul><sub id='5JGv0'></sub></form><legend id='5JGv0'></legend><bdo id='5JGv0'><pre id='5JGv0'><center id='5JGv0'></center></pre></bdo></b><th id='5JGv0'></th></span></q></dt></tr></i><div id='5JGv0'><tfoot id='5JGv0'></tfoot><dl id='5JGv0'><fieldset id='5JGv0'></fieldset></dl></div>
              <legend id='5JGv0'><style id='5JGv0'><dir id='5JGv0'><q id='5JGv0'></q></dir></style></legend>

                • <bdo id='5JGv0'></bdo><ul id='5JGv0'></ul>
                    <tbody id='5JGv0'></tbody>
                  本文介绍了Yii CDbCriteria 加入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我如何编写查询

                  SELECT *
                    FROM doc_docs dd 
                    JOIN doc_access da 
                      ON dd.id=da.doc_id 
                     AND da.user_id=7
                  

                  使用CDbCriteria 语法?

                  推荐答案

                  你实际上不能完全写出来,因为你必须将标准应用到 activerecord 模型来获取主表,但假设你有一个 DocDocs 模型你可以做像这样:

                  You actually cant completely write that since you have to apply the criteria to an activerecord model to obtain the primary table, but assuming you have a DocDocs model you can do it like this:

                  $oDBC = new CDbCriteria();
                  $oDBC->join = 'LEFT JOIN doc_access a ON t.id = a.doc_id and a.user_id = 7'; 
                  
                  $aRecords = DocDocs::model()->findAll($oDBC);
                  

                  虽然如果您为 DocDocs 模型提供与 doc_access 的关系可能会容易得多,但您不必使用 dbcriteria:

                  Although it might be a lot easier if you give your DocDocs model a relation with doc_access, then you don't have to use the dbcriteria:

                  class DocDocs extends CActiveRecord
                  {
                     ... 
                  
                     public function relations()
                     {
                        return array('access' => array(self::HAS_MANY, 'DocAccess', 'doc_id');
                     }
                  
                     ...
                  }
                  
                  $oDocDocs = new DocDocs;
                  $oDocDocs->id = 7;
                  $aRecords = $oDocDocs->access;
                  

                  应该给你一个很好的想法如何开始......

                  Should give you a fairly good idea how to start...

                  这篇关于Yii CDbCriteria 加入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Yii 检查主页 下一篇:Backbone Sync 返回一个空的 $_POST 数组

                  相关文章

                  <legend id='NMFhr'><style id='NMFhr'><dir id='NMFhr'><q id='NMFhr'></q></dir></style></legend>
                  1. <tfoot id='NMFhr'></tfoot>

                    <i id='NMFhr'><tr id='NMFhr'><dt id='NMFhr'><q id='NMFhr'><span id='NMFhr'><b id='NMFhr'><form id='NMFhr'><ins id='NMFhr'></ins><ul id='NMFhr'></ul><sub id='NMFhr'></sub></form><legend id='NMFhr'></legend><bdo id='NMFhr'><pre id='NMFhr'><center id='NMFhr'></center></pre></bdo></b><th id='NMFhr'></th></span></q></dt></tr></i><div id='NMFhr'><tfoot id='NMFhr'></tfoot><dl id='NMFhr'><fieldset id='NMFhr'></fieldset></dl></div>
                      <bdo id='NMFhr'></bdo><ul id='NMFhr'></ul>

                      <small id='NMFhr'></small><noframes id='NMFhr'>