当前位置: 首页>>代码示例>>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;未经允许,请勿转载。