/**
  * Helper for {@see listVersions()} and {@see listVersionsForUser()} that filters duplicates
  * that are the result of the cartesian product performed by createVersionInfoFindQuery()
  *
  * @param \ezcQuerySelect $query
  * @return string[][]
  */
 private function listVersionsHelper($query)
 {
     $query->orderBy($this->dbHandler->quoteColumn('id', 'ezcontentobject_version'));
     $statement = $query->prepare();
     $statement->execute();
     $results = array();
     $previousId = null;
     foreach ($statement->fetchAll(\PDO::FETCH_ASSOC) as $row) {
         if ($row["ezcontentobject_version_id"] == $previousId) {
             continue;
         }
         $previousId = $row["ezcontentobject_version_id"];
         $results[] = $row;
     }
     return $results;
 }
Esempio n. 2
0
 /**
  * Saves the ordered columns in an internal array so we can invert that order
  * if we need to in the limit() workaround
  *
  * @param string $column a column name in the result set
  * @param string $type if the column should be sorted ascending or descending.
  *        you can specify this using ezcQuerySelect::ASC or ezcQuerySelect::DESC
  * @return ezcQuery a pointer to $this
  */
 public function orderBy($column, $type = self::ASC)
 {
     if ($this->invertedOrderString) {
         $this->invertedOrderString .= ', ';
     } else {
         $this->invertedOrderString = 'ORDER BY ';
     }
     $this->invertedOrderString .= $column . ' ' . ($type == self::ASC ? self::DESC : self::ASC);
     return parent::orderBy($column, $type);
 }