Skip to content
Permalink
Browse files

fix for EVO 2.0

  • Loading branch information...
Dmi3yy committed Dec 17, 2018
1 parent b172170 commit 967eece1f59c832ceba78daa5467150bc1652f21
Showing with 15 additions and 5 deletions.
  1. +15 −5 assets/snippets/ajaxSearch/classes/ajaxSearchRequest.class.inc.php
@@ -85,13 +85,14 @@ public function doSearch($searchString, $advSearch, $cfg, $bsf, $fClause)
$this->asSelect = '';
if ($this->_initSearchContext($bsf)) {
$fields = $this->_getFields();
$from = $this->_getFrom($searchString, $advSearch);
$where = $this->_getWhere();
$groupBy = $this->_getGroupBy();
$having = $this->_getHaving($searchString, $advSearch, $fClause);
$orderBy = $this->_getOrderBy();
$this->asSelect = "SELECT $fields FROM $from WHERE $where";
$this->asSelect.= " GROUP BY $groupBy HAVING $having ORDER BY $orderBy";
$this->asSelect = "SELECT $fields FROM $from WHERE $where AND $having";
$this->asSelect.= " GROUP BY $groupBy ORDER BY $orderBy";
if ($this->scJoined !== null) {
$modx->db->query("SET group_concat_max_len = " . GROUP_CONCAT_LENGTH . ";");
}
@@ -103,7 +104,6 @@ public function doSearch($searchString, $advSearch, $cfg, $bsf, $fClause)
$this->asUtil->dbgRecord("End of select");
}
$results = $this->_appendTvs($records);
$modx->db->freeResult($records);
}
return $results;
}
@@ -468,7 +468,15 @@ public function _getWhere()
*/
public function _getGroupBy()
{
return $this->scMain['tb_alias'] . '.' . $this->scMain['id'];
$displayed = '';
if(count($this->scMain['displayed'])) {
$displayed = ', '.$this->scMain['tb_alias'] . '.'.implode(', '.$this->scMain['tb_alias'].'.',$this->scMain['displayed']);
}
$date = '';
if(count($this->scMain['date'])) {
$date = ', '.$this->scMain['tb_alias'] . '.'.implode(', '.$this->scMain['tb_alias'].'.',$this->scMain['date']);
}
return $this->scMain['tb_alias'] . '.' . $this->scMain['id'].$displayed.$date;
}
/**
@@ -492,7 +500,7 @@ public function _getHaving($searchString, $advSearch, $fClause)
$jpref = $joined['tb_alias'];
if (isset($joined['searchable'])) {
foreach ($joined['searchable'] as $searchable) {
$hvg[] = '(' . $jpref . '_' . $searchable . $like . ')';
$hvg[] = '(n' . $jpref . '.' . $searchable . $like . ')';
}
}
}
@@ -503,6 +511,7 @@ public function _getHaving($searchString, $advSearch, $fClause)
$hvg[] = '(`' . $scTv['name'] . '`' . $like . ')';
}
}
} else {
if (isset($this->scJoined)) foreach ($this->scJoined as $joined) {
$jpref = $joined['tb_alias'];
@@ -515,6 +524,7 @@ public function _getHaving($searchString, $advSearch, $fClause)
$hvg[] = '((`' . $scTv['name'] . '`' . $like . ') OR (`' . $scTv['name'] . '` IS NULL))';
}
}
if (count($hvg) > 0) {
$havingSubClause = '(' . implode($whereOper, $hvg) . ')';

0 comments on commit 967eece

Please sign in to comment.
You can’t perform that action at this time.