本文整理汇总了PHP中yii\db\Connection::getQueryBuilder方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getQueryBuilder方法的具体用法?PHP Connection::getQueryBuilder怎么用?PHP Connection::getQueryBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\db\Connection
的用法示例。
在下文中一共展示了Connection::getQueryBuilder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: signEmails
/**
* Sign emails to claim emails send by CURRENT PROCESS, then signed emails will not be retrieved by other processes.
*
* @param bool $signUnassigned Whether to sign email those are not assigned to any server_id (IS NULL).
* Take effects only when column specified by EmailQueueCommand::$sendByCol exists.
* @param bool $renewSignature Whether to renew the signature when sign emails every time.
*
* @return int The numbers of mails signed this time.
*
*/
protected function signEmails($signUnassigned = true, $renewSignature = false)
{
$modelClass = $this->_templateModel;
$where = [$this->signatureAttr => null];
if ($modelClass->hasAttribute($this->assignedToSvrAttr)) {
$where = ['and', $where];
if ($signUnassigned) {
$where[] = ['or', [$this->assignedToSvrAttr => $this->serverID], [$this->assignedToSvrAttr => null]];
} else {
$where[] = [$this->assignedToSvrAttr => $this->serverID];
}
} elseif (!$signUnassigned) {
$msg = "Cannot find any entries to sign, while 'signUnassigned' is false ";
$msg .= "and attribute '{$this->assignedToSvrAttr}' is missing in model class.";
$this->consoleLog($msg, true, Console::FG_YELLOW);
return 0;
}
$cols = [$this->signatureAttr => $this->getSignature($renewSignature)];
$queryBuilder = $this->_db->getQueryBuilder();
$sql = $queryBuilder->update($modelClass::tableName(), $cols, $where, $params);
if ($this->signSize) {
$sql = $queryBuilder->buildOrderByAndLimit($sql, null, $this->signSize, null);
}
return $this->_db->createCommand($sql, $params)->execute();
}