本文整理匯總了PHP中MDB2_Driver_Common::queryCol方法的典型用法代碼示例。如果您正苦於以下問題:PHP MDB2_Driver_Common::queryCol方法的具體用法?PHP MDB2_Driver_Common::queryCol怎麽用?PHP MDB2_Driver_Common::queryCol使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MDB2_Driver_Common
的用法示例。
在下文中一共展示了MDB2_Driver_Common::queryCol方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getDocumentTypes
/**
* 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;
}
示例2: getSearchHistoryPopularWords
/**
* 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;
}