当前位置: 首页>>代码示例>>PHP>>正文


PHP SearchEngine::_generateSearchArticlesWhereString方法代码示例

本文整理汇总了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;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:59,代码来源:articles.class.php


注:本文中的SearchEngine::_generateSearchArticlesWhereString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。