diff --git a/meta/Search.php b/meta/Search.php index db9139e1..9cbb9f8a 100755 --- a/meta/Search.php +++ b/meta/Search.php @@ -581,7 +581,7 @@ protected function runSQLBuilder() { $sqlBuilder = new SearchSQLBuilder(); $sqlBuilder->setSelectLatest($this->selectLatest); - $sqlBuilder->addSchemas($this->schemas); + $sqlBuilder->addSchemas($this->schemas, $this->joins); $sqlBuilder->addColumns($this->columns); $sqlBuilder->addFilters($this->filter); $sqlBuilder->addFilters($this->dynamicFilter); diff --git a/meta/SearchSQLBuilder.php b/meta/SearchSQLBuilder.php index 6a1932db..39b71165 100644 --- a/meta/SearchSQLBuilder.php +++ b/meta/SearchSQLBuilder.php @@ -27,8 +27,9 @@ public function __construct() * Add the schemas to the query * * @param Schema[] $schemas Schema names to query + * @param array $joins Conditionals to be used when joining tables */ - public function addSchemas($schemas) + public function addSchemas($schemas, $joins) { // basic tables $first_table = ''; @@ -38,10 +39,10 @@ public function addSchemas($schemas) $new_pid = false; if ($first_table) { // follow up tables - [$lcol, $rcol] = $this->joins[$schema->getTable()]; + [$lcol, $rcol] = $joins[$schema->getTable()]; if ($lcol->getLabel() == '%pageid%' and $rcol->getLabel() == '%pageid%') { // Simple (default) case where we join on page IDs - $QB->addLeftJoin($first_table, $datatable, $datatable, "$first_table.pid = $datatable.pid"); + $this->qb->addLeftJoin($first_table, $datatable, $datatable, "$first_table.pid = $datatable.pid"); } else { // Custom join on some other columns $lefttable = 'data_' . $lcol->getTable(); @@ -50,7 +51,7 @@ public function addSchemas($schemas) $lefttable, $lcol->getColName(), $righttable, $rcol->getColName(), $rcol->getType() ); - $QB->addLeftJoin($lefttable, $righttable, $righttable, $on); + $this->qb->addLeftJoin($lefttable, $righttable, $righttable, $on); } } else { // first table