當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ActiveQuery::init方法代碼示例

本文整理匯總了PHP中yii\db\ActiveQuery::init方法的典型用法代碼示例。如果您正苦於以下問題:PHP ActiveQuery::init方法的具體用法?PHP ActiveQuery::init怎麽用?PHP ActiveQuery::init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\db\ActiveQuery的用法示例。


在下文中一共展示了ActiveQuery::init方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: init

 public function init()
 {
     $modelClass = $this->modelClass;
     $tableName = $modelClass::tableName();
     //        $this->andWhere([$tableName.'.active' => 1]);
     $this->orderBy('position');
     parent::init();
 }
開發者ID:mickeyur,項目名稱:yii2-menu-item,代碼行數:8,代碼來源:MenuItemQuery.php

示例2: init

 public function init()
 {
     parent::init();
     /* @var $modelClass ActiveRecord */
     $modelClass = $this->modelClass;
     $tableName = $modelClass::tableName();
     $this->select(['m.id', 'm.text', 'm.created_at', 'm.is_new', 'm.sender_id'])->from(['m' => $tableName])->where(['or', ['sender_id' => $this->contactId, 'receiver_id' => $this->userId, 'is_deleted_by_receiver' => 0], ['sender_id' => $this->userId, 'receiver_id' => $this->contactId, 'is_deleted_by_sender' => 0]])->orderBy(['m.id' => SORT_DESC])->asArray();
 }
開發者ID:marciocamello,項目名稱:yii2-simplechat,代碼行數:8,代碼來源:MessageQuery.php

示例3: init

 public function init()
 {
     /**
      * @var $modelClass DpAdminMenuUrlRelation
      */
     $modelClass = $this->modelClass;
     $this->tableName = $modelClass::tableName();
     parent::init();
 }
開發者ID:laojiu,項目名稱:yii2-extjs-rbac,代碼行數:9,代碼來源:DpAdminMenuUrlQuery.php

示例4: init

 public function init()
 {
     parent::init();
     /* @var $modelClass ActiveRecord */
     $modelClass = $this->modelClass;
     $tableName = $modelClass::tableName();
     $subQuery = (new Query())->from($tableName)->select(['message_id' => new Expression('MAX([[id]])'), 'contact_id' => new Expression('IF([[sender_id]] = :userId, [[receiver_id]], [[sender_id]])')])->where(['or', ['receiver_id' => $this->userId, 'is_deleted_by_receiver' => 0], ['sender_id' => $this->userId, 'is_deleted_by_sender' => 0]])->params([':userId' => $this->userId])->groupBy(['contact_id']);
     $this->alias('m')->select(['c.contact_id', 'm.id', 'm.sender_id', 'm.text', 'm.created_at'])->innerJoin(['c' => $subQuery], 'c.message_id = m.id')->orderBy(['c.message_id' => SORT_DESC])->params([':userId' => $this->userId])->asArray();
 }
開發者ID:gofmanaa,項目名稱:yii2-simplechat,代碼行數:9,代碼來源:ConversationQuery.php

示例5: init

 public function init()
 {
     parent::init();
     /* @var $modelClass ActiveRecord */
     $modelClass = $this->modelClass;
     $tableName = $modelClass::tableName();
     $subQuery = (new Query())->from($tableName)->select(['MAX( [[id]] ) AS [[last_message_id]]', 'IF( [[sender_id]] = :userId, [[receiver_id]], [[sender_id]] ) AS [[contact_id]]'])->where(['or', ['receiver_id' => $this->userId, 'is_deleted_by_receiver' => 0], ['sender_id' => $this->userId, 'is_deleted_by_sender' => 0]])->params([':userId' => $this->userId])->groupBy(['[[contact_id]]']);
     $this->select(['contact_id', 'id', 'sender_id', 'text', 'created_at'])->from(['ms' => $subQuery])->innerJoin(['m' => $tableName], '[[last_message_id]] = [[id]]')->orderBy(['id' => SORT_DESC])->params([':userId' => $this->userId]);
 }
開發者ID:marciocamello,項目名稱:yii2-simplechat,代碼行數:9,代碼來源:ConversationQuery.php

示例6: init

 public function init()
 {
     $workplace_id = null;
     if (\Yii::$app->user->can('FilterByWorkplace')) {
         $workplace_id = \Yii::$app->user->identity->workplace_id ? \Yii::$app->user->identity->workplace_id : 0;
     }
     $user_id = null;
     if (\Yii::$app->user->can('FilterByUser')) {
         $user_id = \Yii::$app->user->id ? \Yii::$app->user->id : 0;
     }
     $this->andFilterWhere(['or', ['=', 'user_id', $user_id], ['=', 'workplace_id', $workplace_id]]);
     parent::init();
 }
開發者ID:slavam,項目名稱:placement,代碼行數:13,代碼來源:ResumeQuery.php

示例7: init

 /**
  * Фильтр записей с типом опыта = "Работа"
  * DefaultScope
  */
 public function init()
 {
     parent::init();
     $this->andWhere(['type_id' => 2]);
 }
開發者ID:slavam,項目名稱:placement,代碼行數:9,代碼來源:ExperienceQuery.php

示例8: init

 public function init()
 {
     $this->buildNoInitModel();
     parent::init();
 }
開發者ID:vistart,項目名稱:yii2-models,代碼行數:5,代碼來源:BaseEntityQuery.php

示例9: init

 public function init()
 {
     parent::init();
 }
開發者ID:hucongyang,項目名稱:lulucms2,代碼行數:4,代碼來源:ActiveQuery.php

示例10: init

 public function init()
 {
     parent::init();
     $this->type($this->contentType);
 }
開發者ID:Penton,項目名稱:MoBlog,代碼行數:5,代碼來源:ContentQuery.php

示例11: init

 public function init()
 {
     parent::init();
     $this->alias('m');
 }
開發者ID:bubasuma,項目名稱:yii2-simplechat,代碼行數:5,代碼來源:MessageQuery.php

示例12: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     $expr = new Expression('0');
     $this->select(["{{%{$this->tableName}}}.*", 'last_message_id' => $expr]);
     parent::init();
 }
開發者ID:nanson,項目名稱:yii2-messenger,代碼行數:9,代碼來源:ContactQuery.php

示例13: init

 public function init()
 {
     parent::init();
     $this->type($this->metaType);
 }
開發者ID:Penton,項目名稱:MoBlog,代碼行數:5,代碼來源:MetaQuery.php

示例14: init

 public function init()
 {
     parent::init();
     $this->alias('c');
     $this->select(['last_message_id' => new Expression('MAX([[id]])'), 'contact_id' => new Expression('IF([[sender_id]] = :userId, [[receiver_id]], [[sender_id]])')])->andWhere(['or', ['receiver_id' => new Expression(':userId'), 'is_deleted_by_receiver' => false], ['sender_id' => new Expression(':userId'), 'is_deleted_by_sender' => false]])->groupBy(['contact_id']);
 }
開發者ID:bubasuma,項目名稱:yii2-simplechat,代碼行數:6,代碼來源:ConversationQuery.php

示例15: init

 public function init()
 {
     parent::init();
     $this->alias('m')->select(['m.id', 'm.text', 'm.created_at', 'm.is_new', 'm.sender_id'])->where(['or', ['sender_id' => $this->contactId, 'receiver_id' => $this->userId, 'is_deleted_by_receiver' => 0], ['sender_id' => $this->userId, 'receiver_id' => $this->contactId, 'is_deleted_by_sender' => 0]])->orderBy(['m.id' => SORT_DESC])->asArray();
 }
開發者ID:gofmanaa,項目名稱:yii2-simplechat,代碼行數:5,代碼來源:MessageQuery.php


注:本文中的yii\db\ActiveQuery::init方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。