/** * Gets the available document type shortnames * * @param MDB2_Driver_Common $db the database driver to use to get the * available document type shortnames. * * @return array an array containing the available document type shortnames. * * @throws NateGoSearchDBException if a database error occurs. */ public static function getDocumentTypes(MDB2_Driver_Common $db) { $sql = 'select shortname from NateGoSearchType'; $values = $db->queryCol($sql, 'text'); if (MDB2::isError($values)) { throw new NateGoSearchDBException($values); } return $values; }
/** * Get a list of popular/successful search keywords * * This is used to query the database for a list of keywords from the * NateGoSearchHistory table. The results are based upon the document_count * of each of the keywords and if the words have been searched recently. * * @param MDB2_Driver_Common $db the database driver to use. * @param integer $document_threshold optional. The minimum number of * results in which a word must be * contained to be considered * popular. If not specified, 150 * is used. * @param string $date_threshold optional. Search keywords must be after * this date to be considered popular. Uses * strtotime format. If not specified, * '6 months ago' is used. * * @return array an array of popular search words */ public static function getSearchHistoryPopularWords(MDB2_Driver_Common $db, $document_threshold = 150, $date_threshold = '6 months ago') { $date = strtotime($date_threshold); $date = date('c', $date); $sql = sprintf('select distinct keywords from NateGoSearchHistory where document_count > %s and creation_date > %s', $db->quote($document_threshold, 'integer'), $db->quote($date, 'date')); $words = $db->queryCol($sql, 'text'); if (MDB2::isError($words)) { throw new NateGoSearchDBException($words); } return $words; }