本文整理汇总了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;
}