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


PHP IDatabase::addQuotes方法代码示例

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


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

示例1: buildConditions

 /**
  * Uses the primary key list and the maximal result row from the
  * previous iteration to build an SQL condition sufficient for
  * selecting the next page of results.  All except the final key use
  * `=` conditions while the final key uses a `>` condition
  *
  * Example output:
  * 	  array( '( foo = 42 AND bar > 7 ) OR ( foo > 42 )' )
  *
  * @return array The SQL conditions necessary to select the next set
  *  of rows in the batched query
  */
 protected function buildConditions()
 {
     if (!$this->current) {
         return $this->conditions;
     }
     $maxRow = end($this->current);
     $maximumValues = [];
     foreach ($this->primaryKey as $column) {
         $maximumValues[$column] = $this->db->addQuotes($maxRow->{$column});
     }
     $pkConditions = [];
     // For example: If we have 3 primary keys
     // first run through will generate
     //   col1 = 4 AND col2 = 7 AND col3 > 1
     // second run through will generate
     //   col1 = 4 AND col2 > 7
     // and the final run through will generate
     //   col1 > 4
     while ($maximumValues) {
         $pkConditions[] = $this->buildGreaterThanCondition($maximumValues);
         array_pop($maximumValues);
     }
     $conditions = $this->conditions;
     $conditions[] = sprintf('( %s )', implode(' ) OR ( ', $pkConditions));
     return $conditions;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:38,代码来源:BatchRowIterator.php

示例2: invalidatePages

 /**
  * Invalidate the cache of a list of pages from a single namespace.
  * This is intended for use by subclasses.
  *
  * @param IDatabase $dbw
  * @param int $namespace Namespace number
  * @param array $dbkeys
  */
 public static function invalidatePages(IDatabase $dbw, $namespace, array $dbkeys)
 {
     if ($dbkeys === []) {
         return;
     }
     $dbw->onTransactionIdle(function () use($dbw, $namespace, $dbkeys) {
         $services = MediaWikiServices::getInstance();
         $lbFactory = $services->getDBLoadBalancerFactory();
         // Determine which pages need to be updated.
         // This is necessary to prevent the job queue from smashing the DB with
         // large numbers of concurrent invalidations of the same page.
         $now = $dbw->timestamp();
         $ids = $dbw->selectFieldValues('page', 'page_id', ['page_namespace' => $namespace, 'page_title' => $dbkeys, 'page_touched < ' . $dbw->addQuotes($now)], __METHOD__);
         if (!$ids) {
             return;
         }
         $batchSize = $services->getMainConfig()->get('UpdateRowsPerQuery');
         $ticket = $lbFactory->getEmptyTransactionTicket(__METHOD__);
         foreach (array_chunk($ids, $batchSize) as $idBatch) {
             $dbw->update('page', ['page_touched' => $now], ['page_id' => $idBatch, 'page_touched < ' . $dbw->addQuotes($now)], __METHOD__);
             $lbFactory->commitAndWaitForReplication(__METHOD__, $ticket);
         }
     }, __METHOD__);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:32,代码来源:PurgeJobUtils.php

示例3: getExcludeClause

 /**
  * SQL clause to skip forbidden log types for this user
  *
  * @param IDatabase $db
  * @param string $audience Public/user
  * @param User $user User to check, or null to use $wgUser
  * @return string|bool String on success, false on failure.
  */
 public static function getExcludeClause($db, $audience = 'public', User $user = null)
 {
     global $wgLogRestrictions;
     if ($audience != 'public' && $user === null) {
         global $wgUser;
         $user = $wgUser;
     }
     // Reset the array, clears extra "where" clauses when $par is used
     $hiddenLogs = array();
     // Don't show private logs to unprivileged users
     foreach ($wgLogRestrictions as $logType => $right) {
         if ($audience == 'public' || !$user->isAllowed($right)) {
             $hiddenLogs[] = $logType;
         }
     }
     if (count($hiddenLogs) == 1) {
         return 'log_type != ' . $db->addQuotes($hiddenLogs[0]);
     } elseif ($hiddenLogs) {
         return 'log_type NOT IN (' . $db->makeList($hiddenLogs) . ')';
     }
     return false;
 }
开发者ID:OrBin,项目名称:mediawiki,代码行数:30,代码来源:LogEventsList.php

示例4: intervalCond

 /**
  * Build a SQL expression for a closed interval (i.e. BETWEEN).
  *
  * By specifying a null $start or $end, it is also possible to create
  * half-bounded or unbounded intervals using this function.
  *
  * @param IDatabase $db Database connection
  * @param string $var Field name
  * @param mixed $start First value to include or null
  * @param mixed $end Last value to include or null
  */
 private static function intervalCond(IDatabase $db, $var, $start, $end)
 {
     if ($start === null && $end === null) {
         return "{$var} IS NOT NULL";
     } elseif ($end === null) {
         return "{$var} >= {$db->addQuotes($start)}";
     } elseif ($start === null) {
         return "{$var} <= {$db->addQuotes($end)}";
     } else {
         return "{$var} BETWEEN {$db->addQuotes($start)} AND {$db->addQuotes($end)}";
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:23,代码来源:refreshLinks.php

示例5: getVisitingWatchersCondition

 /**
  * Generates condition for the query used in a batch count visiting watchers.
  *
  * @param IDatabase $db
  * @param array $targetsWithVisitThresholds array of pairs (LinkTarget, last visit threshold)
  * @return string
  */
 private function getVisitingWatchersCondition(IDatabase $db, array $targetsWithVisitThresholds)
 {
     $missingTargets = [];
     $namespaceConds = [];
     foreach ($targetsWithVisitThresholds as list($target, $threshold)) {
         if ($threshold === null) {
             $missingTargets[] = $target;
             continue;
         }
         /* @var LinkTarget $target */
         $namespaceConds[$target->getNamespace()][] = $db->makeList(['wl_title = ' . $db->addQuotes($target->getDBkey()), $db->makeList(['wl_notificationtimestamp >= ' . $db->addQuotes($db->timestamp($threshold)), 'wl_notificationtimestamp IS NULL'], LIST_OR)], LIST_AND);
     }
     $conds = [];
     foreach ($namespaceConds as $namespace => $pageConds) {
         $conds[] = $db->makeList(['wl_namespace = ' . $namespace, '(' . $db->makeList($pageConds, LIST_OR) . ')'], LIST_AND);
     }
     if ($missingTargets) {
         $lb = new LinkBatch($missingTargets);
         $conds[] = $lb->constructSet('wl', $db);
     }
     return $db->makeList($conds, LIST_OR);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:29,代码来源:WatchedItemStore.php

示例6: getFromUntilTargetConds

 /**
  * Creates a query condition part for getting only items before or after the given link target
  * (while ordering using $sort mode)
  *
  * @param IDatabase $db
  * @param LinkTarget $target
  * @param string $op comparison operator to use in the conditions
  * @return string
  */
 private function getFromUntilTargetConds(IDatabase $db, LinkTarget $target, $op)
 {
     return $db->makeList(["wl_namespace {$op} " . $target->getNamespace(), $db->makeList(['wl_namespace = ' . $target->getNamespace(), "wl_title {$op}= " . $db->addQuotes($target->getDBkey())], LIST_AND)], LIST_OR);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:13,代码来源:WatchedItemQueryService.php


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