本文整理匯總了PHP中SearchEngine::_generateSearchArticlesWhereString方法的典型用法代碼示例。如果您正苦於以下問題:PHP SearchEngine::_generateSearchArticlesWhereString方法的具體用法?PHP SearchEngine::_generateSearchArticlesWhereString怎麽用?PHP SearchEngine::_generateSearchArticlesWhereString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SearchEngine
的用法示例。
在下文中一共展示了SearchEngine::_generateSearchArticlesWhereString方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: buildWhere
/**
* builds a WHERE clause for a query
*
* @private
*/
function buildWhere($blogid, $date = -1, $amount = -1, $categoryId = 0, $status = 0, $userId = 0, $maxDate = 0, $searchTerms = "")
{
$postStatus = $status;
$prefix = $this->getPrefix();
if ($blogid == -1) {
$query = "a.blog_id = a.blog_id";
} else {
$query = "a.blog_id = " . Db::qstr($blogid);
}
if ($date != -1) {
// consider the time difference
$blogSettings = $this->blogs->getBlogSettings($blogid);
$timeDifference = $blogSettings->getValue("time_offset");
$SecondsDiff = $timeDifference * 3600;
$query .= " AND FROM_UNIXTIME(UNIX_TIMESTAMP(a.date)+{$SecondsDiff})+0 LIKE '{$date}%'";
}
// the common part "c.id = a.category_id" is needed so that
// we don't get one article row as many times as the amount of categories
// we have... due to the sql 'join' operation we're carrying out
if ($categoryId == -1) {
$query .= " AND c.id = l.category_id AND a.id = l.article_id ";
} else {
if ($categoryId > 0) {
$query .= " AND a.id = l.article_id AND l.category_id = {$categoryId} AND c.id = l.category_id";
} else {
$query .= " AND c.id = l.category_id AND a.id = l.article_id AND c.in_main_page = 1";
}
}
if ($status > 0) {
$query .= " AND a.status = '{$postStatus}'";
}
if ($userId > 0) {
$query .= " AND a.user_id = " . Db::qstr($userId);
}
if ($maxDate > 0) {
$query .= " AND a.date <= '{$maxDate}'";
}
// in case there were some search terms specified as parameters...
if ($searchTerms != "") {
// load the class dynamically so that we don't have to waste memory
// if we're not going to need it!
include_once PLOG_CLASS_PATH . "class/dao/searchengine.class.php";
$searchEngine = new SearchEngine();
// prepare the query string
$searchTerms = $searchEngine->_adaptSearchString($searchTerms);
$whereString = $searchEngine->_generateSearchArticlesWhereString($searchTerms);
// and add it to the current search
$query .= " AND {$whereString} ";
}
if ($categoryId <= 0) {
$query .= " GROUP BY a.id ";
}
return $query;
}