本文整理汇总了PHP中QueryBuilder::insertIgnore方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::insertIgnore方法的具体用法?PHP QueryBuilder::insertIgnore怎么用?PHP QueryBuilder::insertIgnore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::insertIgnore方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parseLogForFloodingIps
/**
* Parse requests log and blacklist flooding IPs.
* Should be called by cron job every minute.
*/
public function parseLogForFloodingIps()
{
$tablesToLock = array(Tbl::get('TBL_SECURITY_REQUESTS_LOG'), Tbl::get('TBL_SECURITY_FLOODER_IPS'));
MySqlDbManager::getDbObject()->startTransaction();
$qb = new QueryBuilder();
$qbSelect = new QueryBuilder();
$qbSelect->select(new Field('ip'))->from(Tbl::get('TBL_SECURITY_REQUESTS_LOG'))->where($qbSelect->expr()->greaterEqual(new Field('count'), $this->config->requestsLimit));
$qb->insertIgnore(Tbl::get('TBL_SECURITY_FLOODER_IPS'))->fields('ip')->values($qbSelect);
$this->query->exec($qb->getSQL());
$this->query->exec("TRUNCATE TABLE `" . Tbl::get('TBL_SECURITY_REQUESTS_LOG') . "`");
if (!MySqlDbManager::getDbObject()->commit()) {
MySqlDbManager::getDbObject()->rollBack();
}
}
示例2: insertSession
public function insertSession($inviterUserId, $invitedUserId)
{
if (empty($inviterUserId) or !is_numeric($inviterUserId)) {
throw new InvalidArgumentException("Invalid inviterUser specified!");
}
if (empty($invitedUserId) or !is_numeric($invitedUserId)) {
throw new InvalidArgumentException("Invalid invitedUser specified!");
}
$qb = new QueryBuilder();
$qb->insertIgnore(Tbl::get('TBL_CHAT_SESSIONS'))->values(array('inviter_user_id' => $inviterUserId, 'invited_user_id' => $invitedUserId));
$this->query->exec($qb->getSQL());
$newSessionId = $this->query->getLastInsertId();
//$this->insertSessionLog($inviterUserId, $invitedUserId);
return $newSessionId;
}