From 90873dba9eac60239e1a3d062ee7130c5b296776 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 9 Jun 2014 19:50:13 -0700 Subject: [PATCH] CRM-14765 - Allow fillTempTable() to return multiple pieces of information --- CRM/Contact/Form/Search/Custom/FullText.php | 3 ++- .../Custom/FullText/AbstractPartialQuery.php | 16 +++++++++++----- CRM/Contact/Form/Search/Custom/FullText/File.php | 4 +++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/CRM/Contact/Form/Search/Custom/FullText.php b/CRM/Contact/Form/Search/Custom/FullText.php index 719124ffde..f00b4b47b8 100644 --- a/CRM/Contact/Form/Search/Custom/FullText.php +++ b/CRM/Contact/Form/Search/Custom/FullText.php @@ -235,7 +235,8 @@ CREATE TEMPORARY TABLE {$this->_entityIDTableName} ( /** @var $partialQuery CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery */ if (!$this->_table || $this->_table == $partialQuery->getName()) { if ($partialQuery->isActive()) { - $this->_foundRows[$partialQuery->getName()] = $partialQuery->fillTempTable($this->_text, $this->_entityIDTableName, $this->_tableName, $this->_limitClause, $this->_limitDetailClause); + $result = $partialQuery->fillTempTable($this->_text, $this->_entityIDTableName, $this->_tableName, $this->_limitClause, $this->_limitDetailClause); + $this->_foundRows[$partialQuery->getName()] = $result['count']; } } } diff --git a/CRM/Contact/Form/Search/Custom/FullText/AbstractPartialQuery.php b/CRM/Contact/Form/Search/Custom/FullText/AbstractPartialQuery.php index aad88082ba..6eb226418c 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/AbstractPartialQuery.php +++ b/CRM/Contact/Form/Search/Custom/FullText/AbstractPartialQuery.php @@ -76,7 +76,8 @@ abstract class CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery { * NULL if no limit; or array(0 => $limit, 1 => $offset) * @param array|NULL $detailLimit final limit (applied when building $detailTable) * NULL if no limit; or array(0 => $limit, 1 => $offset) - * @return int number of matches + * @return array keys: match-descriptor + * - count: int */ public abstract function fillTempTable($queryText, $entityIDTableName, $detailTable, $queryLimit, $detailLimit); @@ -118,8 +119,12 @@ AND cf.html_type IN ( 'Text', 'TextArea', 'RichTextEditor' ) /** * @param string $queryText - * @param array $tables - * @return int the total number of matches + * @param array $tables a list of places to query. Keys may be: + * - sql: an array of SQL queries to execute + * - final: an array of SQL queries to execute at the end + * - *: All other keys are treated as table names + * @return array keys: match-descriptor + * - count: int */ function runQueries($queryText, &$tables, $entityIDTableName, $limit) { $sql = "TRUNCATE {$entityIDTableName}"; @@ -192,8 +197,9 @@ GROUP BY {$tableValues['id']} } } - $rowCount = "SELECT count(*) FROM {$entityIDTableName}"; - return CRM_Core_DAO::singleValueQuery($rowCount); + return array( + 'count' => CRM_Core_DAO::singleValueQuery("SELECT count(*) FROM {$entityIDTableName}") + ); } /** diff --git a/CRM/Contact/Form/Search/Custom/FullText/File.php b/CRM/Contact/Form/Search/Custom/FullText/File.php index 8b2fc40c2a..239f994eef 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/File.php +++ b/CRM/Contact/Form/Search/Custom/FullText/File.php @@ -83,7 +83,9 @@ class CRM_Contact_Form_Search_Custom_FullText_File extends CRM_Contact_Form_Sear ts('File Search') ); } - return count($solrResponse->docs); + return array( + 'count' => count($solrResponse->docs), + ); //return $solrResponse->numFound; //return count($matches); } -- 2.25.1