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


PHP Connection::delete方法代码示例

本文整理汇总了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());
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:10,代码来源:DblogClearLogConfirmForm.php

示例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;
 }
开发者ID:ibonelli,项目名称:DrupalConsole,代码行数:32,代码来源:LogClearCommand.php

示例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();
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:10,代码来源:DblogClearLogConfirmForm.php

示例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;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:15,代码来源:AliasStorage.php

示例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();
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:18,代码来源:UserData.php

示例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);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:EntityDatabaseStorage.php

示例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));
 }
开发者ID:ibonelli,项目名称:DrupalConsole,代码行数:30,代码来源:LoginCleanAttemptsCommand.php

示例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();
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:11,代码来源:SessionManager.php

示例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;
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:19,代码来源:StringDatabaseStorage.php

示例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);
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:11,代码来源:DatabaseBackend.php

示例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);
     }
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:12,代码来源:BatchStorage.php

示例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);
 }
开发者ID:chi-teck,项目名称:drupal-code-generator,代码行数:20,代码来源:_rest_resource.php

示例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;
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:12,代码来源:DatabaseStorage.php

示例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.
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:13,代码来源:DatabaseBackend.php

示例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;
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:13,代码来源:SessionHandler.php


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