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


PHP Connection::queryRange方法代码示例

本文整理汇总了PHP中Drupal\Core\Database\Connection::queryRange方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::queryRange方法的具体用法?PHP Connection::queryRange怎么用?PHP Connection::queryRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Database\Connection的用法示例。


在下文中一共展示了Connection::queryRange方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: claimItem

 /**
  * {@inheritdoc}
  */
 public function claimItem($lease_time = 30)
 {
     // Claim an item by updating its expire fields. If claim is not successful
     // another thread may have claimed the item in the meantime. Therefore loop
     // until an item is successfully claimed or we are reasonably sure there
     // are no unclaimed items left.
     while (TRUE) {
         $item = $this->connection->queryRange('SELECT data, created, item_id FROM {queue} q WHERE expire = 0 AND name = :name ORDER BY created, item_id ASC', 0, 1, array(':name' => $this->name))->fetchObject();
         if ($item) {
             // Try to update the item. Only one thread can succeed in UPDATEing the
             // same row. We cannot rely on REQUEST_TIME because items might be
             // claimed by a single consumer which runs longer than 1 second. If we
             // continue to use REQUEST_TIME instead of the current time(), we steal
             // time from the lease, and will tend to reset items before the lease
             // should really expire.
             $update = $this->connection->update('queue')->fields(array('expire' => time() + $lease_time))->condition('item_id', $item->item_id)->condition('expire', 0);
             // If there are affected rows, this update succeeded.
             if ($update->execute()) {
                 $item->data = unserialize($item->data);
                 return $item;
             }
         } else {
             // No items currently available to claim.
             return FALSE;
         }
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:30,代码来源:DatabaseQueue.php

示例2: exists

 /**
  * Implements Drupal\Core\Config\StorageInterface::exists().
  */
 public function exists($name)
 {
     try {
         return (bool) $this->connection->queryRange('SELECT 1 FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :name', 0, 1, array(':collection' => $this->collection, ':name' => $name), $this->options)->fetchField();
     } catch (\Exception $e) {
         // If we attempt a read without actually having the database or the table
         // available, just return FALSE so the caller can handle it.
         return FALSE;
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:13,代码来源:DatabaseStorage.php

示例3: read

 /**
  * {@inheritdoc}
  */
 public function read($sid)
 {
     $data = '';
     if (!empty($sid)) {
         // Read the session data from the database.
         $query = $this->connection->queryRange('SELECT session FROM {sessions} WHERE sid = :sid', 0, 1, [':sid' => Crypt::hashBase64($sid)]);
         $data = (string) $query->fetchField();
     }
     return $data;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:13,代码来源:SessionHandler.php

示例4: updateIndex

 /**
  * {@inheritdoc}
  */
 public function updateIndex(NodeInterface $node)
 {
     $nid = $node->id();
     $count = $this->database->query("SELECT COUNT(cid) FROM {comment_field_data} c INNER JOIN {forum_index} i ON c.entity_id = i.nid WHERE c.entity_id = :nid AND c.field_name = 'comment_forum' AND c.entity_type = 'node' AND c.status = :status AND c.default_langcode = 1", array(':nid' => $nid, ':status' => CommentInterface::PUBLISHED))->fetchField();
     if ($count > 0) {
         // Comments exist.
         $last_reply = $this->database->queryRange("SELECT cid, name, created, uid FROM {comment_field_data} WHERE entity_id = :nid AND field_name = 'comment_forum' AND entity_type = 'node' AND status = :status AND default_langcode = 1 ORDER BY cid DESC", 0, 1, array(':nid' => $nid, ':status' => CommentInterface::PUBLISHED))->fetchObject();
         $this->database->update('forum_index')->fields(array('comment_count' => $count, 'last_comment_timestamp' => $last_reply->created))->condition('nid', $nid)->execute();
     } else {
         // Comments do not exist.
         // @todo This should be actually filtering on the desired node language
         $this->database->update('forum_index')->fields(array('comment_count' => 0, 'last_comment_timestamp' => $node->getCreatedTime()))->condition('nid', $nid)->execute();
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:17,代码来源:ForumIndexStorage.php

示例5: validateConfigurationForm

 /**
  * {@inheritdoc}
  */
 public function validateConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     $exists = (bool) $this->connection->queryRange('SELECT 1 FROM {users_field_data} WHERE uid = :uid AND default_langcode = 1', 0, 1, array(':name' => $form_state->getValue('owner_uid')))->fetchField();
     if (!$exists) {
         $form_state->setErrorByName('owner_uid', t('Enter a valid username.'));
     }
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:10,代码来源:AssignOwnerNode.php

示例6: validateConfigurationForm

 /**
  * {@inheritdoc}
  */
 public function validateConfigurationForm(array &$form, FormStateInterface $form_state)
 {
     $exists = (bool) $this->connection->queryRange('SELECT 1 FROM {users} WHERE name = :name', 0, 1, array(':name' => $form_state['values']['owner_name']))->fetchField();
     if (!$exists) {
         form_set_error('owner_name', $form_state, t('Enter a valid username.'));
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:AssignOwnerNode.php

示例7: languageAliasExists

 /**
  * {@inheritdoc}
  */
 public function languageAliasExists()
 {
     try {
         return (bool) $this->connection->queryRange('SELECT 1 FROM {url_alias} WHERE langcode <> :langcode', 0, 1, array(':langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED))->fetchField();
     } catch (\Exception $e) {
         $this->catchException($e);
         return FALSE;
     }
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:12,代码来源:AliasStorage.php

示例8: updateIndex

 /**
  * {@inheritdoc}
  */
 public function updateIndex()
 {
     // Interpret the cron limit setting as the maximum number of nodes to index
     // per cron run.
     $limit = (int) $this->searchSettings->get('index.cron_limit');
     $result = $this->database->queryRange("SELECT n.nid, MAX(sd.reindex) FROM {node} n LEFT JOIN {search_dataset} sd ON sd.sid = n.nid AND sd.type = :type WHERE sd.sid IS NULL OR sd.reindex <> 0 GROUP BY n.nid ORDER BY MAX(sd.reindex) is null DESC, MAX(sd.reindex) ASC, n.nid ASC", 0, $limit, array(':type' => $this->getPluginId()), array('target' => 'replica'));
     $nids = $result->fetchCol();
     if (!$nids) {
         return;
     }
     $node_storage = $this->entityManager->getStorage('node');
     foreach ($node_storage->loadMultiple($nids) as $node) {
         $this->indexNode($node);
     }
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:18,代码来源:NodeSearch.php

示例9: exists

 /**
  * {@inheritdoc}
  */
 public function exists($alias, $source, $language = LanguageInterface::LANGCODE_NOT_SPECIFIED)
 {
     return (bool) $this->database->queryRange("SELECT pid FROM {url_alias} WHERE source <> :source AND alias = :alias AND langcode IN (:language, :language_none) ORDER BY langcode DESC, pid DESC", 0, 1, array(':source' => $source, ':alias' => $alias, ':language' => $language, ':language_none' => LanguageInterface::LANGCODE_NOT_SPECIFIED))->fetchField();
 }
开发者ID:malabya,项目名称:angular-demo,代码行数:7,代码来源:AliasStorageHelper.php


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