本文整理汇总了PHP中QueryBuilder::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryBuilder::delete方法的具体用法?PHP QueryBuilder::delete怎么用?PHP QueryBuilder::delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryBuilder
的用法示例。
在下文中一共展示了QueryBuilder::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteHost
public static function deleteHost(Host $host)
{
if (empty($host->id)) {
throw new InvalidArgumentException("HostId is empty!");
}
$qb = new QueryBuilder();
$qb->delete(Tbl::get('TBL_HOSTS', 'Host'))->where($qb->expr()->equal(new Field('id'), $host->id));
$sql = MySqlDbManager::getQueryObject();
$sql->exec($qb->getSQL());
}
示例2: setControllerTemplateByHost
public static function setControllerTemplateByHost(Host $host, $controller, $template)
{
$sql = MySqlDbManager::getQueryObject();
$qb = new QueryBuilder();
if (!empty($controller) or !empty($template)) {
$qb->insert(Tbl::get('TBL_HOST_CONTROLLER_TEMPLATE'))->values(array('host_id' => $host->id, 'controller' => $controller, 'template' => $template))->onDuplicateKeyUpdate()->set(new Field('controller'), $controller)->set(new Field('template'), $template);
} else {
$qb->delete(Tbl::get('TBL_HOST_CONTROLLER_TEMPLATE'))->where($qb->expr()->equal(new Field('host_id'), $host->id));
}
$sql->exec($qb->getSQL());
return $sql->affected();
}
示例3: fillUsersGps
public function fillUsersGps($userId, $leafId)
{
$qb = new QueryBuilder();
$qb->delete(Tbl::get('TBL_USERS_GPS'))->where($qb->expr()->equal(new Field('user_id'), $userId));
$this->query->exec($qb->getSQL());
$gpsTree = $this->getNodeTree($leafId);
foreach ($gpsTree as $treeNode) {
$qb = new QueryBuilder();
$qb->insert(Tbl::get('TBL_USERS_GPS'))->values(array('user_id' => $userId, 'node_id' => $treeNode["node_id"]));
$this->query->exec($qb->getSQL());
}
}
示例4: deleteAllAliasesForTextValue
public function deleteAllAliasesForTextValue(TextValue $textValue)
{
if (empty($textValue->id)) {
throw new InvalidArgumentException("Text Value ID have to be specified");
}
if (!is_numeric($textValue->id)) {
throw new InvalidArgumentException("Text Value ID have to be integer");
}
$qb = new QueryBuilder();
$qb->delete(Tbl::get('TBL_TEXTS_ALIASES'))->where($qb->expr()->equal(new Field("value_id"), $textValue->id));
$this->query->exec($qb->getSQL());
return $this->query->affected();
}
示例5: deleteGroup
public function deleteGroup(TextsGroup $group)
{
if (empty($group->id)) {
throw new InvalidArgumentException("Group ID have to be specified");
}
if (!is_numeric($group->id)) {
throw new InvalidArgumentException("Group ID have to be integer");
}
$qb = new QueryBuilder();
$qb->delete(Tbl::get('TBL_TEXTS_GROUPS'))->where($qb->expr()->equal(new Field("id"), $group->id));
$this->query->exec($qb->getSQL());
return $this->query->affected();
}
示例6: hookInvalidLoginAttempt
public function hookInvalidLoginAttempt($params)
{
if ($this->config->AuxConfig->loginBruteForceProtectionEnabled) {
if (isset($_SERVER['REMOTE_ADDR'])) {
$sql = MySqlDbManager::getQueryObject();
$qb = new QueryBuilder();
$sql->exec($qb->select(new Field('count'))->from(Tbl::get('TBL_SECURITY_INVALID_LOGINS_LOG', 'RequestLimiter'))->where($qb->expr()->equal(new Field('ip'), $_SERVER['REMOTE_ADDR']))->getSQL());
$failedAuthCount = $sql->fetchField('count');
$newFailedAuthCount = $failedAuthCount + 1;
if ($newFailedAuthCount >= $this->config->AuxConfig->failedLoginLimit) {
Reg::get(ConfigManager::getConfig("Security", "RequestLimiter")->Objects->RequestLimiter)->blockIP();
$qb = new QueryBuilder();
$sql->exec($qb->delete(Tbl::get('TBL_SECURITY_INVALID_LOGINS_LOG', 'RequestLimiter'))->where($qb->expr()->equal(new Field('ip'), $_SERVER['REMOTE_ADDR']))->getSQL());
throw new RequestLimiterTooManyAuthTriesException("Too many unsucessful authorization tries.");
}
$qb = new QueryBuilder();
$sql->exec($qb->insert(Tbl::get('TBL_SECURITY_INVALID_LOGINS_LOG', 'RequestLimiter'))->values(array('ip' => $_SERVER['REMOTE_ADDR']))->onDuplicateKeyUpdate()->set(new Field('count'), $qb->expr()->sum(new Field('count'), 1))->getSQL());
}
}
}
示例7: cleanUp
/**
* CleanUp codes from DB that are too old
*/
public function cleanUp()
{
$time = 60 * 60 * 24 * $this->config->cleanUpTimeOut;
$qb = new QueryBuilder();
$orX = new Orx();
$andX1 = new Andx();
$andX2 = new Andx();
$andX1->add($qb->expr()->less(new Func('UNIX_TIMESTAMP', new Field('issue_date')), $qb->expr()->diff(new Func('UNIX_TIMESTAMP', new Func('NOW')), $time)));
$andX1->add($qb->expr()->equal(new Field('not_cleanable'), 0));
$andX1->add($qb->expr()->isNull(new Field('valid_until')));
$andX2->add($qb->expr()->isNotNull(new Field('valid_until')));
$andX2->add($qb->expr()->less(new Field('valid_until'), new Func('NOW')));
$orX->add($andX1);
$orX->add($andX2);
$qb->delete(Tbl::get('TBL_ONE_TIME_CODES'))->where($orX);
$this->query->exec($qb->getSQL());
return $this->query->affected();
}
示例8: setAnswersByIds
/**
* Set user answers by their ids
*
* @param array $answers an array containing user's answers
*/
public function setAnswersByIds($answers)
{
if (is_array($answers)) {
$qb = new QueryBuilder();
$qb->delete(Tbl::get('TBL_PROFILE_SAVE'))->where($qb->expr()->equal(new Field("user_id"), $this->userId));
$this->query->exec($qb->getSQL());
foreach ($answers as $answer) {
if (is_numeric($answer)) {
$qb = new QueryBuilder();
$qb->insert(Tbl::get('TBL_PROFILE_SAVE'))->values(array("user_id" => $this->userId, "profile_id" => $answer));
$this->query->exec($qb->getSQL());
}
}
$this->initUserAnswers();
} else {
throw new UnexpectedValueException("\$answers have to array");
}
}
示例9: saveField
/**
* Save custom entered field
*
* @param int $user_id
* @param int $field_id
* @param string $value
* @return bool
*/
public function saveField($user_id, $field_id, $value)
{
$value = addslashes($value);
$qb = new QueryBuilder();
$qb->delete(Tbl::get('TBL_CUST_SAVE'))->where($qb->expr()->equal(new Field('user_id'), $user_id))->andWhere($qb->expr()->equal(new Field('field_id'), $field_id));
$this->query->exec($qb->getSQL());
$qb = new QueryBuilder();
$qb->insert(Tbl::get('TBL_CUST_SAVE'))->values(array('user_id' => $user_id, 'field_id' => $field_id, 'text' => $value));
if ($this->query->exec($qb->getSQL())) {
return true;
}
return false;
}
示例10: clearTimedOutSessions
public function clearTimedOutSessions()
{
$qb = new QueryBuilder();
$qb->delete(Tbl::get('TBL_CHAT_SESSIONS'))->where($qb->expr()->equal(new Field('closed'), 1))->andWhere($qb->expr()->greaterEqual($qb->expr()->diff(new Func('NOW'), new Field('closed_date')), $qb->expr()->prod($this->sessionClearTimeout, 60)));
$this->query->exec($qb->getSQL());
return $this->query->affected();
}
示例11: deleteDBConfigAlias
/**
* Delete current host and Lang id alias value for config DB
* @param ConfigDB $configDB
* @param unknown_type $aliasHostLangId
* @throws InvalidArgumentException
*/
public static function deleteDBConfigAlias(ConfigDB $configDB, $aliasHostLangId)
{
if (empty($configDB)) {
throw new InvalidArgumentException("ConfigDB object is empty!");
}
if (!is_numeric($configDB->id)) {
throw new InvalidArgumentException("ConfigDB object's id is not numeric!");
}
if (!is_numeric($aliasHostLangId)) {
throw new InvalidArgumentException("Alias Host Language id is not numeric!");
}
$qb = new QueryBuilder();
$qb->delete(Tbl::get("TBL_CONFIGS"))->where($qb->expr()->equal(new Field('alias_of'), $configDB->id))->andWhere($qb->expr()->equal(new Field('host_lang_id'), $aliasHostLangId));
$sql = MySqlDbManager::getQueryObject();
$sql->exec($qb->getSQL());
}
示例12: wipeConversationMessage
public function wipeConversationMessage($conversationMessageId)
{
if (empty($conversationMessageId) or !is_numeric($conversationMessageId)) {
throw new InvalidIntegerArgumentException("\$conversationMessageId have to be non zero integer.");
}
// Get message
$filter = new ConversationMessagesFilter();
$filter->setId($conversationMessageId);
$message = $this->getConversationMessage($filter, true);
$qb = new QueryBuilder();
$qb->delete(Tbl::get('TBL_CONVERSATION_MESSAGES'))->where($qb->expr()->equal(new Field('id'), $message->id));
$affected = $this->query->exec($qb->getSQL())->affected();
$this->correctConversationReadStatus($message->uuid, $message->senderId);
$this->correctConversationHasAttachment($message->uuid, $message->senderId);
$this->correctConversationReadStatus($message->uuid, $message->receiverId);
$this->correctConversationHasAttachment($message->uuid, $message->receiverId);
return $affected;
}
示例13: unblockIP
/**
* Unblock blocked IP
* @param string $ip
*/
public function unblockIP($ip = null)
{
if ($ip === null) {
$ip = $_SERVER['REMOTE_ADDR'];
}
$qb = new QueryBuilder();
$qb->delete(Tbl::get('TBL_SECURITY_FLOODER_IPS'))->where($qb->expr()->equal(new Field("ip"), $ip));
$this->query->exec($qb->getSQL());
}
示例14: deleteHostsLanguage
public static function deleteHostsLanguage(Host $host, Language $language)
{
$sql = MySqlDbManager::getQueryObject();
$qb = new QueryBuilder();
$qb->delete(Tbl::get('TBL_HOST_LANGUAGE'))->where($qb->expr()->equal(new Field('host_id'), $host->id))->andWhere($qb->expr()->equal(new Field('lang_id'), $language->id));
$sql->exec($qb->getSQL());
}
示例15: clearTimedOutInvitations
public function clearTimedOutInvitations()
{
$qb = new QueryBuilder();
$qb->delete(Tbl::get('TBL_CHAT_INVITATIONS'))->where($qb->expr()->greaterEqual($qb->expr()->diff(new Func('NOW'), new Field('date')), $qb->expr()->prod($this->invitationClearTimeout, 60)));
$this->query->exec($qb->getSQL());
return $this->query->affected();
}