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


PHP SelectInterface::getFields方法代码示例

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


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

示例1: preExecute

 /**
  * Preprocesses and validates the query.
  *
  * @return bool
  *   TRUE if the validation was successful, FALSE if not.
  *
  * @throws \Drupal\Core\Database\Query\FieldsOverlapException
  * @throws \Drupal\Core\Database\Query\NoFieldsException
  */
 protected function preExecute()
 {
     // Confirm that the user did not try to specify an identical
     // field and default field.
     if (array_intersect($this->insertFields, $this->defaultFields)) {
         throw new FieldsOverlapException('You may not specify the same field to have a value and a schema-default value.');
     }
     if (!empty($this->fromQuery)) {
         // We have to assume that the used aliases match the insert fields.
         // Regular fields are added to the query before expressions, maintain the
         // same order for the insert fields.
         // This behavior can be overridden by calling fields() manually as only the
         // first call to fields() does have an effect.
         $this->fields(array_merge(array_keys($this->fromQuery->getFields()), array_keys($this->fromQuery->getExpressions())));
     } else {
         // Don't execute query without fields.
         if (count($this->insertFields) + count($this->defaultFields) == 0) {
             throw new NoFieldsException('There are no fields available to insert with.');
         }
     }
     // If no values have been added, silently ignore this query. This can happen
     // if values are added conditionally, so we don't want to throw an
     // exception.
     if (!isset($this->insertValues[0]) && count($this->insertFields) > 0 && empty($this->fromQuery)) {
         return FALSE;
     }
     return TRUE;
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:37,代码来源:Insert.php

示例2:

 public function &getFields()
 {
     return $this->query->getFields();
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:4,代码来源:SelectExtender.php

示例3: getTemporaryResultsTable

 /**
  * Creates a temporary table from a select query.
  *
  * Will return the name of a table containing the item IDs of all results, or
  * FALSE on failure.
  *
  * @param \Drupal\Core\Database\Query\SelectInterface $db_query
  *   The select query whose results should be stored in the temporary table.
  *
  * @return string|false
  *   The name of the temporary table, or FALSE on failure.
  */
 protected function getTemporaryResultsTable(SelectInterface $db_query) {
   // We only need the id field, not the score.
   $fields = &$db_query->getFields();
   unset($fields['score']);
   if (count($fields) != 1 || !isset($fields['item_id'])) {
     $this->getLogger()->warning('Error while adding facets: only "item_id" field should be used, used are: @fields.', array('@fields' => implode(', ', array_keys($fields))));
     return FALSE;
   }
   $expressions = &$db_query->getExpressions();
   $expressions = array();
   $db_query->distinct();
   if (!$db_query->preExecute()) {
     return FALSE;
   }
   $args = $db_query->getArguments();
   return $this->database->queryTemporary((string) $db_query, $args);
 }
开发者ID:jkyto,项目名称:agolf,代码行数:29,代码来源:Database.php

示例4: getTemporaryResultsTable

 /**
  * Creates a temporary table from a select query.
  *
  * Will return the name of a table containing the item IDs of all results, or
  * FALSE on failure.
  *
  * @param \Drupal\Core\Database\Query\SelectInterface $db_query
  *   The select query whose results should be stored in the temporary table.
  *
  * @return string|false
  *   The name of the temporary table, or FALSE on failure.
  */
 protected function getTemporaryResultsTable(SelectInterface $db_query)
 {
     // We only need the id field, not the score.
     $fields =& $db_query->getFields();
     unset($fields['score']);
     if (count($fields) != 1 || !isset($fields['item_id'])) {
         $this->getLogger()->warning('Error while adding facets: only "item_id" field should be used, used are: @fields.', array('@fields' => implode(', ', array_keys($fields))));
         return FALSE;
     }
     $expressions =& $db_query->getExpressions();
     $expressions = array();
     // If there's a GROUP BY for item_id, we leave that, all others need to be
     // discarded.
     $group_by =& $db_query->getGroupBy();
     $group_by = array_intersect_key($group_by, array('t.item_id' => TRUE));
     $db_query->distinct();
     if (!$db_query->preExecute()) {
         return FALSE;
     }
     $args = $db_query->getArguments();
     try {
         $result = $this->database->queryTemporary((string) $db_query, $args);
     } catch (\PDOException $e) {
         watchdog_exception('search_api', $e, '%type while trying to create a temporary table: @message in %function (line %line of %file).');
         return FALSE;
     }
     return $result;
 }
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:40,代码来源:Database.php


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