本文整理汇总了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();
}
示例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();
}
示例3: init
public function init()
{
/**
* @var $modelClass DpAdminMenuUrlRelation
*/
$modelClass = $this->modelClass;
$this->tableName = $modelClass::tableName();
parent::init();
}
示例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();
}
示例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]);
}
示例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();
}
示例7: init
/**
* Фильтр записей с типом опыта = "Работа"
* DefaultScope
*/
public function init()
{
parent::init();
$this->andWhere(['type_id' => 2]);
}
示例8: init
public function init()
{
$this->buildNoInitModel();
parent::init();
}
示例9: init
public function init()
{
parent::init();
}
示例10: init
public function init()
{
parent::init();
$this->type($this->contentType);
}
示例11: init
public function init()
{
parent::init();
$this->alias('m');
}
示例12: init
/**
* @inheritdoc
*/
public function init()
{
$expr = new Expression('0');
$this->select(["{{%{$this->tableName}}}.*", 'last_message_id' => $expr]);
parent::init();
}
示例13: init
public function init()
{
parent::init();
$this->type($this->metaType);
}
示例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']);
}
示例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();
}