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


PHP PMF_Db::search方法代码示例

本文整理汇总了PHP中PMF_Db::search方法的典型用法代码示例。如果您正苦于以下问题:PHP PMF_Db::search方法的具体用法?PHP PMF_Db::search怎么用?PHP PMF_Db::search使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PMF_Db的用法示例。


在下文中一共展示了PMF_Db::search方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: search

 /**
  * The main search function for the full text search
  *
  * @param   string  $searchterm     Text/Number (solution id)
  * @param   boolean $allLanguages   true to search over all languages
  * @param   boolean $hasMore        true to disable the results paging
  * @param   boolean $instantRespnse true to use it for Instant Response
  * @return  array
  */
 public function search($searchterm, $allLanguages = true, $hasMore = false, $instantResponse = false)
 {
     $fdTable = SQLPREFIX . 'faqdata';
     $fcrTable = SQLPREFIX . 'faqcategoryrelations';
     $condition = array($fdTable . '.active' => "'yes'");
     // Search in all or one category?
     if (!is_null($this->categoryId)) {
         $selectedCategory = array($fcrTable . '.category_id' => $searchcategory);
         $condition = array_merge($selectedCategory, $condition);
     }
     if (!$allLanguages && !is_numeric($searchterm)) {
         $selectedLanguage = array($fdTable . '.lang' => "'" . $this->language . "'");
         $condition = array_merge($selectedLanguage, $condition);
     }
     if (is_numeric($searchterm)) {
         // search for the solution_id
         $result = $this->db->search($fdTable, array($fdTable . '.id AS id', $fdTable . '.lang AS lang', $fdTable . '.solution_id AS solution_id', $fcrTable . '.category_id AS category_id', $fdTable . '.thema AS question', $fdTable . '.content AS answer'), $fcrTable, array($fdTable . '.id = ' . $fcrTable . '.record_id', $fdTable . '.lang = ' . $fcrTable . '.record_lang'), array($fdTable . '.solution_id'), $searchterm, $condition);
     } else {
         $result = $this->db->search($fdTable, array($fdTable . '.id AS id', $fdTable . '.lang AS lang', $fcrTable . '.category_id AS category_id', $fdTable . '.thema AS question', $fdTable . '.content AS answer'), $fcrTable, array($fdTable . '.id = ' . $fcrTable . '.record_id', $fdTable . '.lang = ' . $fcrTable . '.record_lang'), array($fdTable . '.thema', $fdTable . '.content', $fdTable . '.keywords'), $searchterm, $condition);
     }
     if ($result) {
         $num = $this->db->numRows($result);
     }
     if ($num == 0) {
         return array();
     } else {
         return $this->db->fetchAll($result);
     }
 }
开发者ID:nosch,项目名称:phpMyFAQ,代码行数:38,代码来源:Search.php

示例2: getAllRelatedById

 /**
  * Returns all relevant Articles for a FAQ record
  *
  * @param   integer $record_id
  * @param   string  $thema
  * @return   string
  * @since   2006-08-29
  * @author  Thomas Zeithaml <info@spider-trap.de>
  */
 public function getAllRelatedById($record_id, $article_name, $keywords)
 {
     global $sids, $PMF_CONF;
     $relevantslisting = '';
     $begriffe = str_replace('-', ' ', $article_name) . $keywords;
     $i = $last_id = 0;
     $result = $this->db->search(SQLPREFIX . "faqdata", array(SQLPREFIX . "faqdata.id AS id", SQLPREFIX . "faqdata.lang AS lang", SQLPREFIX . "faqcategoryrelations.category_id AS category_id", SQLPREFIX . "faqdata.thema AS thema", SQLPREFIX . "faqdata.content AS content"), SQLPREFIX . "faqcategoryrelations", array(SQLPREFIX . "faqdata.id = " . SQLPREFIX . "faqcategoryrelations.record_id", SQLPREFIX . "faqdata.lang = " . SQLPREFIX . "faqcategoryrelations.record_lang"), array(SQLPREFIX . "faqdata.thema", SQLPREFIX . "faqdata.content", SQLPREFIX . "faqdata.keywords"), $begriffe, array(SQLPREFIX . "faqdata.active" => "'yes'"));
     while (($row = $this->db->fetch_object($result)) && $i < $PMF_CONF['records.numberOfRelatedArticles']) {
         if ($row->id == $record_id || $row->id == $last_id) {
             continue;
         }
         $relevantslisting .= '' == $relevantslisting ? '<ul>' : '';
         $relevantslisting .= '<li>';
         $url = sprintf('%saction=artikel&amp;cat=%d&amp;id=%d&amp;artlang=%s', $sids, $row->category_id, $row->id, $row->lang);
         $oLink = new PMF_Link(PMF_Link::getSystemRelativeUri() . '?' . $url);
         $oLink->itemTitle = $row->thema;
         $oLink->text = $row->thema;
         $oLink->tooltip = $row->thema;
         $relevantslisting .= $oLink->toHtmlAnchor() . '</li>';
         $i++;
         $last_id = $row->id;
     }
     $relevantslisting .= $i > 0 ? '</ul>' : '';
     return '' == $relevantslisting ? '-' : $relevantslisting;
 }
开发者ID:noon,项目名称:phpMyFAQ,代码行数:34,代码来源:Relation.php


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