Merge branch 'master' of https://github.com/alchemy-fr/Phraseanet into PHRAS-2430_Port_to_41-Advance_search_refacto_Restore_Query

This commit is contained in:
Harrys
2019-03-19 18:09:18 +04:00

View File

@@ -127,20 +127,21 @@ class Fetcher
private function getExecutedStatement() private function getExecutedStatement()
{ {
if (!$this->statement) { if (!$this->statement) {
$sql = "SELECT r.record_id" $sql = "SELECT r.*, c.asciiname AS collection_name, subdef.width, subdef.height, subdef.size\n"
. ", r.coll_id AS collection_id" . " FROM ((\n"
. ", c.asciiname AS collection_name" . " SELECT r.record_id, r.coll_id AS collection_id, r.uuid, r.status AS flags_bitfield, r.sha256,\n"
. ", r.uuid" . " r.originalname AS original_name, r.mime, r.type, r.parent_record_id,\n"
. ", r.status AS flags_bitfield" . " r.credate AS created_on, r.moddate AS updated_on, r.coll_id\n"
. ", r.sha256" // -- TODO rename in "hash" . " FROM record r\n"
. ", r.originalname AS original_name" . " -- WHERE\n"
. ", r.mime, r.type, r.parent_record_id, r.credate AS created_on, r.moddate AS updated_on" . " ORDER BY " . $this->options->getPopulateOrderAsSQL() . " " . $this->options->getPopulateDirectionAsSQL() . "\n"
. ", subdef.width, subdef.height, subdef.size" . " LIMIT :offset, :limit\n"
. " FROM (record r INNER JOIN coll c ON (c.coll_id = r.coll_id))" . " ) AS r\n"
. " LEFT JOIN subdef ON subdef.record_id=r.record_id AND subdef.name='document'" . " INNER JOIN coll c ON (c.coll_id = r.coll_id)\n"
. " -- WHERE" . " )\n"
. " ORDER BY " . $this->options->getPopulateOrderAsSQL() . " " . $this->options->getPopulateDirectionAsSQL() . " LEFT JOIN\n"
. " LIMIT :offset, :limit"; . " subdef ON subdef.record_id=r.record_id AND subdef.name='document'\n"
. " ORDER BY " . $this->options->getPopulateOrderAsSQL() . " " . $this->options->getPopulateDirectionAsSQL() . "";
$where = $this->delegate->buildWhereClause(); $where = $this->delegate->buildWhereClause();
$sql = str_replace('-- WHERE', $where, $sql); $sql = str_replace('-- WHERE', $where, $sql);