From d99dca5251945fe60b9b4c3eba2c95c4063e1a22 Mon Sep 17 00:00:00 2001 From: Septdir Date: Wed, 25 Apr 2018 03:33:21 +0300 Subject: [PATCH] add advanced where clause param --- libraries/src/Language/Associations.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libraries/src/Language/Associations.php b/libraries/src/Language/Associations.php index 1aacc695dfb78..851cc7bc07e41 100644 --- a/libraries/src/Language/Associations.php +++ b/libraries/src/Language/Associations.php @@ -29,6 +29,7 @@ class Associations * @param string $pk The name of the primary key in the given $table. * @param string $aliasField If the table has an alias field set it here. Null to not use it * @param string $catField If the table has a catid field set it here. Null to not use it + * @param array $advClause Array with advanced where clause use c as parent column key, c2 as associations column key * * @return array The associated items * @@ -36,13 +37,13 @@ class Associations * * @throws \Exception */ - public static function getAssociations($extension, $tablename, $context, $id, $pk = 'id', $aliasField = 'alias', $catField = 'catid') + public static function getAssociations($extension, $tablename, $context, $id, $pk = 'id', $aliasField = 'alias', $catField = 'catid', $advClause = array()) { // To avoid doing duplicate database queries. static $multilanguageAssociations = array(); // Multilanguage association array key. If the key is already in the array we don't need to run the query again, just return it. - $queryKey = implode('|', func_get_args()); + $queryKey = implode('|', array($extension, $tablename, $context, $id)); if (!isset($multilanguageAssociations[$queryKey])) { @@ -97,6 +98,15 @@ public static function getAssociations($extension, $tablename, $context, $id, $p $query->where('c.extension = ' . $db->quote($extension)); } + // Advanced where clause + if (!empty($advClause)) + { + foreach ($advClause as $clause) + { + $query->where($clause); + } + } + $db->setQuery($query); try