select() public method

select() accepts an arbitrary number of parameters. Each parameter must contain either the name of a column or an array containing the names of the columns. Each call to select() appends columns to the list of columns that will be used in the query. Example: $q->select( 'column1', 'column2' ); The same could also be written $columns[] = 'column1'; $columns[] = 'column2; $q->select( $columns ); or using several calls $q->select( 'column1' )->select( 'column2' ); Each of above code produce SQL clause 'SELECT column1, column2' for the query.
public select ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery
return eZ\Publish\Core\Persistence\Database\SelectQuery returns a pointer to $this.
 /**
  * Apply selects to the query.
  *
  * Returns the name of the (aliased) column, which information should be
  * used for sorting.
  *
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  * @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause $sortClause
  * @param int $number
  *
  * @return string
  */
 public function applySelect(SelectQuery $query, SortClause $sortClause, $number)
 {
     /** @var \eZ\Publish\API\Repository\Values\Content\Query\SortClause\Target\MapLocationTarget $target */
     $target = $sortClause->targetData;
     $externalTable = $this->getSortTableName($number, 'ezgmaplocation');
     /*
      * Note: this formula is precise only for short distances.
      */
     $longitudeCorrectionByLatitude = pow(cos(deg2rad($target->latitude)), 2);
     $distanceExpression = $query->expr->add($query->expr->mul($query->expr->sub($this->dbHandler->quoteColumn('latitude', $externalTable), $query->bindValue($target->latitude)), $query->expr->sub($this->dbHandler->quoteColumn('latitude', $externalTable), $query->bindValue($target->latitude))), $query->expr->mul($query->expr->sub($this->dbHandler->quoteColumn('longitude', $externalTable), $query->bindValue($target->longitude)), $query->expr->sub($this->dbHandler->quoteColumn('longitude', $externalTable), $query->bindValue($target->longitude)), $query->bindValue($longitudeCorrectionByLatitude)));
     $query->select($query->alias($distanceExpression, $column1 = $this->getSortColumnName($number)));
     return array($column1);
 }
Example #2
0
 /**
  * Apply selects to the query
  *
  * Returns the name of the (aliased) column, which information should be
  * used for sorting.
  *
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  * @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause $sortClause
  * @param int $number
  *
  * @return string
  */
 public function applySelect(SelectQuery $query, SortClause $sortClause, $number)
 {
     $query->select($query->alias($this->dbHandler->quoteColumn('node_id', 'ezcontentobject_tree'), $column = $this->getSortColumnName($number)));
     return $column;
 }
 /**
  * Creates an array of select columns for $tableName.
  *
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $q
  * @param string $tableName
  */
 protected function selectColumns(SelectQuery $q, $tableName)
 {
     foreach ($this->columns[$tableName] as $col) {
         $q->select($this->dbHandler->aliasedColumn($q, $col, $tableName));
     }
 }
 /**
  * Apply selects to the query
  *
  * Returns the name of the (aliased) column, which information should be
  * used for sorting.
  *
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  * @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause $sortClause
  * @param int $number
  *
  * @return string
  */
 public function applySelect(SelectQuery $query, SortClause $sortClause, $number)
 {
     $query->select($query->alias($this->dbHandler->quoteColumn("modified", "ezcontentobject"), $column = $this->getSortColumnName($number)));
     return $column;
 }
 /**
  * Apply selects to the query
  *
  * Returns the name of the (aliased) column, which information should be
  * used for sorting.
  *
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  * @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause $sortClause
  * @param int $number
  *
  * @return string
  */
 public function applySelect(SelectQuery $query, SortClause $sortClause, $number)
 {
     $query->select($query->alias($this->dbHandler->quoteColumn('priority', 'main_tree'), $column = $this->getSortColumnName($number)));
     return $column;
 }
Example #6
0
 /**
  * Apply selects to the query.
  *
  * Returns the name of the (aliased) column, which information should be
  * used for sorting.
  *
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  * @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause $sortClause
  * @param int $number
  *
  * @return string
  */
 public function applySelect(SelectQuery $query, SortClause $sortClause, $number)
 {
     $query->select($query->alias($query->expr->not($query->expr->isNull($this->dbHandler->quoteColumn('sort_key_int', $this->getSortTableName($number)))), $column1 = $this->getSortColumnName($number . '_null')), $query->alias($query->expr->not($query->expr->isNull($this->dbHandler->quoteColumn('sort_key_string', $this->getSortTableName($number)))), $column2 = $this->getSortColumnName($number . '_bis_null')), $query->alias($this->dbHandler->quoteColumn('sort_key_int', $this->getSortTableName($number)), $column3 = $this->getSortColumnName($number)), $query->alias($this->dbHandler->quoteColumn('sort_key_string', $this->getSortTableName($number)), $column4 = $this->getSortColumnName($number . '_bis')));
     return array($column1, $column2, $column3, $column4);
 }
Example #7
0
 /**
  * Apply selects to the query
  *
  * Returns the name of the (aliased) column, which information should be
  * used for sorting.
  *
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  * @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause $sortClause
  * @param int $number
  *
  * @return string
  */
 public function applySelect(SelectQuery $query, SortClause $sortClause, $number)
 {
     $query->select($query->alias($this->dbHandler->quoteColumn("sort_key_int", $this->getSortTableName($number)), $column1 = $this->getSortColumnName($number)), $query->alias($this->dbHandler->quoteColumn("sort_key_string", $this->getSortTableName($number)), $column2 = $this->getSortColumnName($number . "_bis")));
     return array($column1, $column2);
 }
 /**
  * Apply selects to the query
  *
  * Returns the name of the (aliased) column, which information should be
  * used for sorting.
  *
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  * @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause $sortClause
  * @param int $number
  *
  * @return string
  */
 public function applySelect(SelectQuery $query, SortClause $sortClause, $number)
 {
     $query->select($query->alias($this->dbHandler->quoteColumn("name", $this->getSortTableName($number)), $column = $this->getSortColumnName($number)));
     return $column;
 }
 /**
  * Set query selecting word ids for content object (method was extracted to be reusable).
  *
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  */
 private function setContentObjectWordsSelectQuery(SelectQuery $query)
 {
     $query->select('word_id')->from($this->dbHandler->quoteTable('ezsearch_object_word_link'))->where($query->expr->eq($this->dbHandler->quoteColumn('contentobject_id'), ':contentId'));
 }
 /**
  * Initializes main selection $query.
  *
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  */
 protected function initSelectQuery(SelectQuery $query)
 {
     /** @var \eZ\Publish\Core\Persistence\Database\DatabaseHandler $databaseHandler */
     $databaseHandler = $this->getContainer()->get('ezpublish.connection');
     $query->select($databaseHandler->quoteColumn('id', 'ezcontentobject'), $databaseHandler->quoteColumn('current_version', 'ezcontentobject'), $databaseHandler->quoteColumn('initial_language_id', 'ezcontentobject'), $query->expr->count('distinct ezcontentobject_attribute.language_code'))->from('ezcontentobject')->innerJoin($databaseHandler->quoteTable('ezcontentobject_attribute'), $query->expr->lAnd($query->expr->eq($databaseHandler->quoteColumn('id', 'ezcontentobject'), $databaseHandler->quoteColumn('contentobject_id', 'ezcontentobject_attribute')), $query->expr->eq($databaseHandler->quoteColumn('current_version', 'ezcontentobject'), $databaseHandler->quoteColumn('version', 'ezcontentobject_attribute')), $query->expr->gt($query->expr->bitAnd($databaseHandler->quoteColumn('language_id', 'ezcontentobject_attribute'), $query->bindValue(1, null, PDO::PARAM_INT)), $query->bindValue(0, null, PDO::PARAM_INT))))->where($query->expr->lAnd($query->expr->gt($query->expr->bitAnd($databaseHandler->quoteColumn('language_mask', 'ezcontentobject'), $query->bindValue(1, null, PDO::PARAM_INT)), $query->bindValue(0, null, PDO::PARAM_INT)), $query->expr->neq($query->expr->bitAnd($query->expr->bitAnd($databaseHandler->quoteColumn('language_mask', 'ezcontentobject'), $query->bindValue(-2, null, PDO::PARAM_INT)), $query->expr->sub($query->expr->bitAnd($databaseHandler->quoteColumn('language_mask', 'ezcontentobject'), $query->bindValue(-2, null, PDO::PARAM_INT)), $query->bindValue(1, null, PDO::PARAM_INT))), $query->bindValue(0, null, PDO::PARAM_INT))))->groupBy($databaseHandler->quoteColumn('id', 'ezcontentobject'))->having($query->expr->gt($query->expr->count('distinct ezcontentobject_attribute.language_code'), $query->bindValue(1, null, PDO::PARAM_INT)));
 }
 /**
  * Set columns to be fetched from the database
  *
  * This method is intended to be overwritten by derived classes in order to
  * add additional columns to be fetched from the database. Please do not
  * forget to call the parent when overwriting this method.
  *
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $selectQuery
  * @param int $fieldId
  * @param int $versionNo
  *
  * @return void
  */
 protected function setFetchColumns(SelectQuery $selectQuery, $fieldId, $versionNo)
 {
     $connection = $this->getConnection();
     $selectQuery->select($connection->quoteColumn('filename'), $connection->quoteColumn('mime_type'), $connection->quoteColumn('original_filename'));
 }