本文整理汇总了PHP中Drupal\Core\Database\Connection::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::delete方法的具体用法?PHP Connection::delete怎么用?PHP Connection::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Database\Connection
的用法示例。
在下文中一共展示了Connection::delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$_SESSION['dblog_overview_filter'] = array();
$this->connection->delete('watchdog')->execute();
drupal_set_message($this->t('Database log cleared.'));
$form_state->setRedirectUrl($this->getCancelUrl());
}
示例2: clearEvents
/**
* @param DrupalStyle $io
* @param $eventType
* @param $eventSeverity
* @param $userId
* @return bool
*/
protected function clearEvents(DrupalStyle $io, $eventType, $eventSeverity, $userId)
{
$severity = RfcLogLevel::getLevels();
$query = $this->database->delete('watchdog');
if ($eventType) {
$query->condition('type', $eventType);
}
if ($eventSeverity) {
if (!in_array($eventSeverity, $severity)) {
$io->error(sprintf($this->trans('commands.database.log.clear.messages.invalid-severity'), $eventSeverity));
return false;
}
$query->condition('severity', array_search($eventSeverity, $severity));
}
if ($userId) {
$query->condition('uid', $userId);
}
$result = $query->execute();
if (!$result) {
$io->error($this->trans('commands.database.log.clear.messages.clear-error'));
return false;
}
$io->success($this->trans('commands.database.log.clear.messages.clear-sucess'));
return true;
}
示例3: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state)
{
$_SESSION['dblog_overview_filter'] = array();
$this->connection->delete('watchdog')->execute();
drupal_set_message($this->t('Database log cleared.'));
$form_state['redirect_route'] = $this->getCancelRoute();
}
示例4: delete
/**
* {@inheritdoc}
*/
public function delete($conditions)
{
$path = $this->load($conditions);
$query = $this->connection->delete('url_alias');
foreach ($conditions as $field => $value) {
$query->condition($field, $value);
}
$deleted = $query->execute();
// @todo Switch to using an event for this instead of a hook.
$this->moduleHandler->invokeAll('path_delete', array($path));
return $deleted;
}
示例5: delete
/**
* {@inheritdoc}
*/
public function delete($module = NULL, $uid = NULL, $name = NULL)
{
$query = $this->connection->delete('users_data');
// Cast scalars to array so we can consistently use an IN condition.
if (isset($module)) {
$query->condition('module', (array) $module, 'IN');
}
if (isset($uid)) {
$query->condition('uid', (array) $uid, 'IN');
}
if (isset($name)) {
$query->condition('name', (array) $name, 'IN');
}
$query->execute();
}
示例6: doDelete
/**
* {@inheritdoc}
*/
protected function doDelete($entities)
{
$ids = array_keys($entities);
$this->database->delete($this->entityType->getBaseTable())->condition($this->idKey, $ids, 'IN')->execute();
// Reset the cache as soon as the changes have been applied.
$this->resetCache($ids);
}
示例7: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$uid = $input->getArgument('uid');
$account = User::load($uid);
if (!$account) {
// Error loading User entity.
$io->error(sprintf($this->trans('commands.user.login.clear.attempts.errors.invalid-user'), $uid));
return 1;
}
// Define event name and identifier.
$event = 'user.failed_login_user';
// Identifier is created by uid and IP address,
// Then we defined a generic identifier.
$identifier = "{$account->id()}-";
// Retrieve current database connection.
$schema = $this->database->schema();
$flood = $schema->findTables('flood');
if (!$flood) {
$io->error($this->trans('commands.user.login.clear.attempts.errors.no-flood'));
return 1;
}
// Clear login attempts.
$this->database->delete('flood')->condition('event', $event)->condition('identifier', $this->database->escapeLike($identifier) . '%', 'LIKE')->execute();
// Command executed successful.
$io->success(sprintf($this->trans('commands.user.login.clear.attempts.messages.successful'), $uid));
}
示例8: delete
/**
* {@inheritdoc}
*/
public function delete($uid)
{
// Nothing to do if we are not allowed to change the session.
if (!$this->writeSafeHandler->isSessionWritable() || $this->isCli()) {
return;
}
$this->connection->delete('sessions')->condition('uid', $uid)->execute();
}
示例9: dbDelete
/**
* Creates delete query.
*
* @param string $table
* The table name.
* @param array $keys
* Array with object keys indexed by field name.
*
* @return \Drupal\Core\Database\Query\Delete
* Returns a new Delete object for the injected database connection.
*/
protected function dbDelete($table, $keys)
{
$query = $this->connection->delete($table, $this->options);
foreach ($keys as $field => $value) {
$query->condition($field, $value);
}
return $query;
}
示例10: garbageCollection
/**
* {@inheritdoc}
*/
public function garbageCollection()
{
try {
$return = $this->connection->delete(static::TABLE_NAME)->condition('expiration', REQUEST_TIME, '<')->execute();
} catch (\Exception $e) {
$this->catchException($e);
}
}
示例11: cleanup
/**
* {@inheritdoc}
*/
public function cleanup()
{
try {
// Cleanup the batch table and the queue for failed batches.
$this->connection->delete('batch')->condition('timestamp', REQUEST_TIME - 864000, '<')->execute();
} catch (\Exception $e) {
$this->catchException($e);
}
}
示例12: delete
/**
* Responds to entity DELETE requests.
*
* @param int $id
* The ID of the record.
*
* @return \Drupal\rest\ModifiedResourceResponse
* The HTTP response object.
*
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function delete($id)
{
// Make sure the record still exists.
$this->loadRecord($id);
$this->dbConnection->delete('example_foo')->condition('id', $id)->execute();
$this->logger->notice('Deleted record with ID %id.');
// Deleted responses have an empty body.
return new ModifiedResourceResponse(NULL, 204);
}
示例13: deleteAll
/**
* {@inheritdoc}
*/
public function deleteAll($prefix = '')
{
try {
$options = array('return' => Database::RETURN_AFFECTED) + $this->options;
return (bool) $this->connection->delete($this->table, $options)->condition('name', $prefix . '%', 'LIKE')->condition('collection', $this->collection)->execute();
} catch (\Exception $e) {
return FALSE;
}
}
示例14: garbageCollection
/**
* Implements Drupal\Core\Cache\CacheBackendInterface::garbageCollection().
*/
public function garbageCollection()
{
try {
$this->connection->delete($this->bin)->condition('expire', Cache::PERMANENT, '<>')->condition('expire', REQUEST_TIME, '<')->execute();
} catch (\Exception $e) {
// If the table does not exist, it surely does not have garbage in it.
// If the table exists, the next garbage collection will clean up.
// There is nothing to do.
}
}
示例15: gc
/**
* {@inheritdoc}
*/
public function gc($lifetime)
{
// Be sure to adjust 'php_value session.gc_maxlifetime' to a large enough
// value. For example, if you want user sessions to stay in your database
// for three weeks before deleting them, you need to set gc_maxlifetime
// to '1814400'. At that value, only after a user doesn't log in after
// three weeks (1814400 seconds) will his/her session be removed.
$this->connection->delete('sessions')->condition('timestamp', REQUEST_TIME - $lifetime, '<')->execute();
return TRUE;
}