当前位置: 首页>>代码示例>>PHP>>正文


PHP Connection::getQueryBuilder方法代码示例

本文整理汇总了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();
 }
开发者ID:thinker-g,项目名称:yii2-hermes-mailing,代码行数:35,代码来源:DefaultController.php


注:本文中的yii\db\Connection::getQueryBuilder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。