/** * Prepares the search and executes it * * @param string $searchTerm Search term * * @return resource * * @throws PMF_Search_Exception */ public function search($searchTerm) { if (is_numeric($searchTerm) && $this->_config->get('search.searchForSolutionId')) { parent::search($searchTerm); } else { $query = sprintf("\n SELECT\n %s\n FROM \n %s %s %s\n WHERE\n %s\n %s", $this->getResultColumns(), $this->getTable(), $this->getJoinedTable(), $this->getJoinedColumns(), $this->getMatchClause($searchTerm), $this->getConditions()); $this->resultSet = $this->_config->getDb()->query($query); } return $this->resultSet; }
/** * Prepares the search and executes it * * @param string $searchTerm Search term * * @return resource * * @throws PMF_Search_Exception */ public function search($searchTerm) { if (is_numeric($searchTerm)) { parent::search($searchTerm); } else { $query = sprintf("\n SELECT\n %s\n FROM \n %s %s %s\n WHERE\n (%s) ILIKE ('%%%s%%')\n %s", $this->getResultColumns(), $this->getTable(), $this->getJoinedTable(), $this->getJoinedColumns(), $this->getMatchingColumns(), $this->dbHandle->escape_string($searchTerm), $this->getConditions()); $this->resultSet = $this->dbHandle->query($query); } return $this->resultSet; }
/** * Prepares the search and executes it * * @param string $searchTerm Search term * * @return resource * * @throws PMF_Search_Exception */ public function search($searchTerm) { if (is_numeric($searchTerm)) { parent::search($searchTerm); } else { $enableRelevance = PMF_Configuration::getInstance()->get('search.enableRelevance'); $columns = $this->getResultColumns(); $columns .= $enableRelevance ? $this->getMatchingColumnsAsResult($searchTerm) : ''; $orderBy = $enableRelevance ? 'ORDER BY ' . $this->getMatchingOrder() : ''; $query = sprintf("\n SELECT\n %s\n FROM\n %s %s %s %s\n WHERE\n (%s) ILIKE ('%%%s%%')\n %s\n %s", $columns, $this->getTable(), $this->getJoinedTable(), $this->getJoinedColumns(), $enableRelevance ? ", plainto_tsquery('" . $this->dbHandle->escape_string($searchTerm) . "') query " : '', $this->getMatchingColumns(), $this->dbHandle->escape_string($searchTerm), $this->getConditions(), $orderBy); $this->resultSet = $this->dbHandle->query($query); } return $this->resultSet; }
/** * Prepares the search and executes it * * @param string $searchTerm Search term * * @return resource * * @throws PMF_Search_Exception */ public function search($searchTerm) { if (is_numeric($searchTerm)) { parent::search($searchTerm); } else { $enableRelevance = PMF_Configuration::getInstance()->get('search.enableRelevance'); $columns = $this->getResultColumns(); $columns .= $enableRelevance ? $this->getMatchingColumnsAsResult($searchTerm) : ''; $orderBy = $enableRelevance ? 'ORDER BY ' . $this->getMatchingOrder() . ' DESC' : ''; $query = sprintf("\n SELECT\n %s\n FROM \n %s %s %s\n WHERE\n MATCH (%s) AGAINST ('*%s*' IN BOOLEAN MODE)\n %s\n %s", $columns, $this->getTable(), $this->getJoinedTable(), $this->getJoinedColumns(), $this->getMatchingColumns(), $this->dbHandle->escapeString($searchTerm), $this->getConditions(), $orderBy); $this->resultSet = $this->dbHandle->query($query); } return $this->resultSet; }
/** * Prepares the search and executes it * * @param string $searchTerm Search term * * @return resource * * @throws PMF_Search_Exception */ public function search($searchTerm) { if (is_numeric($searchTerm)) { parent::search($searchTerm); } else { $query = sprintf("\n SELECT\n %s\n FROM \n %s %s %s\n WHERE\n MATCH (%s) AGAINST ('%s' IN BOOLEAN MODE)\n %s", $this->getResultColumns(), $this->getTable(), $this->getJoinedTable(), $this->getJoinedColumns(), $this->getMatchingColumns(), $this->dbHandle->escape_string($searchTerm), $this->getConditions()); $this->resultSet = $this->dbHandle->query($query); // Fallback for searches with less than three characters if (false == $this->resultSet) { $query = sprintf("\n SELECT\n %s\n FROM \n %s %s %s\n WHERE\n %s\n %s", $this->getResultColumns(), $this->getTable(), $this->getJoinedTable(), $this->getJoinedColumns(), $this->getMatchClause($searchTerm), $this->getConditions()); } $this->resultSet = $this->dbHandle->query($query); } return $this->resultSet; }
/** * Prepares the search and executes it * * @param string $searchTerm Search term * * @return resource * * @throws PMF_Search_Exception */ public function search($searchTerm) { if (is_numeric($searchTerm) && $this->_config->get('search.searchForSolutionId')) { parent::search($searchTerm); } else { $enableRelevance = $this->_config->get('search.enableRelevance'); $columns = $this->getResultColumns(); $columns .= $enableRelevance ? $this->getMatchingColumnsAsResult($searchTerm) : ''; $orderBy = $enableRelevance ? 'ORDER BY ' . $this->getMatchingOrder() . ' DESC' : ''; $chars = array("‘", "’", "“", "”", "–", "—", "…"); $replace = array("'", "'", '"', '"', '-', '--', '...'); $searchTerm = str_replace($chars, $replace, $searchTerm); $query = sprintf("\n SELECT\n %s\n FROM \n %s %s %s\n WHERE\n MATCH (%s) AGAINST ('%s' IN BOOLEAN MODE)\n %s\n %s", $columns, $this->getTable(), $this->getJoinedTable(), $this->getJoinedColumns(), $this->getMatchingColumns(), $this->_config->getDb()->escape($searchTerm), $this->getConditions(), $orderBy); $this->resultSet = $this->_config->getDb()->query($query); // Fallback for searches with less than three characters if (0 == $this->_config->getDb()->numRows($this->resultSet)) { $query = sprintf("\n SELECT\n %s\n FROM \n %s %s %s\n WHERE\n %s\n %s", $this->getResultColumns(), $this->getTable(), $this->getJoinedTable(), $this->getJoinedColumns(), $this->getMatchClause($searchTerm), $this->getConditions()); } $this->resultSet = $this->_config->getDb()->query($query); } return $this->resultSet; }
/** * Prepares the search and executes it * * @param string $searchTerm Search term * * @return resource * * @throws PMF_Search_Exception */ public function search($searchTerm) { if (is_numeric($searchTerm)) { parent::search($searchTerm); } else { $enableRelevance = PMF_Configuration::getInstance()->get('search.enableRelevance'); $columns = $this->getResultColumns(); $columns .= $enableRelevance ? $this->getMatchingColumnsAsResult($searchTerm) : ''; $orderBy = $enableRelevance ? 'ORDER BY ' . $this->getMatchingOrder() . ' DESC' : ''; $chars = array(chr(150), chr(147), chr(148), chr(146), chr(34), '"', '"'); $replace = array("-", "\"", "\"", "'", "\"", "\"", "\""); $searchTerm = str_replace($chars, $replace, $searchTerm); $query = sprintf("\n SELECT\n %s\n FROM \n %s %s %s\n WHERE\n MATCH (%s) AGAINST ('%s' IN BOOLEAN MODE)\n %s\n %s", $columns, $this->getTable(), $this->getJoinedTable(), $this->getJoinedColumns(), $this->getMatchingColumns(), $this->dbHandle->escape_string($searchTerm), $this->getConditions(), $orderBy); $this->resultSet = $this->dbHandle->query($query); // Fallback for searches with less than three characters if (0 == $this->dbHandle->num_rows($this->resultSet)) { $query = sprintf("\n SELECT\n %s\n FROM \n %s %s %s\n WHERE\n %s\n %s", $this->getResultColumns(), $this->getTable(), $this->getJoinedTable(), $this->getJoinedColumns(), $this->getMatchClause($searchTerm), $this->getConditions()); } $this->resultSet = $this->dbHandle->query($query); } return $this->resultSet; }