/** * Helper for {@see listVersions()} and {@see listVersionsForUser()} that filters duplicates * that are the result of the cartesian product performed by createVersionInfoFindQuery(). * * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query * * @return string[][] */ private function listVersionsHelper(SelectQuery $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; }
/** * Assert query result as correct. * * Builds text representations of the asserted and fetched query result, * based on a eZ\Publish\Core\Persistence\Database\SelectQuery object. Compares them using classic diff for * maximum readability of the differences between expectations and real * results. * * The expectation MUST be passed as a two dimensional array containing * rows of columns. * * @param array $expectation * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query * @param string $message */ public static function assertQueryResult(array $expectation, SelectQuery $query, $message = null) { $statement = $query->prepare(); $statement->execute(); $result = array(); while ($row = $statement->fetch(\PDO::FETCH_ASSOC)) { $result[] = $row; } return self::assertEquals(self::getResultTextRepresentation($expectation), self::getResultTextRepresentation($result), $message); }
/** * Loads field data for given $pass. * * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query * @param int $bulkCount * @param int $pass * * @return array */ protected function loadData(SelectQuery $query, $bulkCount, $pass) { $query->limit($bulkCount, $pass * $bulkCount); $stmt = $query->prepare(); $stmt->execute(); return $stmt->fetchAll(PDO::FETCH_ASSOC); }