本文整理汇总了PHP中search::getSearchResults方法的典型用法代码示例。如果您正苦于以下问题:PHP search::getSearchResults方法的具体用法?PHP search::getSearchResults怎么用?PHP search::getSearchResults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类search
的用法示例。
在下文中一共展示了search::getSearchResults方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: page_not_found
public function page_not_found()
{
global $router;
$params = $router->params;
unset($params['controller']);
unset($params['action']);
$terms = empty($params[0]) ? '' : $params[0];
expCSS::pushToHead(array("unique" => "search-results", "link" => $this->asset_path . "css/results.css"));
$search = new search();
$page = new expPaginator(array('model' => 'search', 'controller' => $this->params['controller'], 'action' => $this->params['action'], 'records' => $search->getSearchResults(implode(' ', $params)), 'order' => 'score', 'dir' => 'DESC'));
assign_to_template(array('page' => $page, 'terms' => $terms));
}
示例2: search
public function search()
{
global $db, $user;
if (INCLUDE_AJAX_SEARCH == 1) {
$qry = trim($this->params['query']);
if (!empty($qry)) {
$search = new search();
$r = $search->getSearchResults($this->params['query']);
}
}
//$this->params['query'] = str_ireplace('-','\-',$this->params['query']);
$terms = explode(" ", $this->params['query']);
$sql = "select DISTINCT(p.id) as id, p.title, model, sef_url, f.id as fileid, match (p.title,p.body) against ('" . $this->params['query'] . "*' IN BOOLEAN MODE) as score ";
$sql .= " from " . $db->prefix . "product as p INNER JOIN " . $db->prefix . "content_expFiles as cef ON p.id=cef.content_id INNER JOIN " . $db->prefix . "expFiles as f ON cef.expFiles_id = f.id WHERE ";
if (!($user->is_admin || $user->is_acting_admin)) {
$sql .= '(p.active_type=0 OR p.active_type=1) AND ';
}
$sql .= " match (p.title,p.body) against ('" . $this->params['query'] . "*' IN BOOLEAN MODE) AND p.parent_id=0 GROUP BY p.id ";
$sql .= "order by score desc LIMIT 10";
$firstObs = $db->selectObjectsBySql($sql);
foreach ($firstObs as $set) {
$set->weight = 1;
unset($set->score);
$res[$set->model] = $set;
}
$sql = "select DISTINCT(p.id) as id, p.title, model, sef_url, f.id as fileid from " . $db->prefix . "product as p INNER JOIN " . $db->prefix . "content_expFiles as cef ON p.id=cef.content_id INNER JOIN " . $db->prefix . "expFiles as f ON cef.expFiles_id = f.id WHERE ";
if (!($user->is_admin || $user->is_acting_admin)) {
$sql .= '(p.active_type=0 OR p.active_type=1) AND ';
}
$sql .= " (p.model like '%" . $this->params['query'] . "%' ";
$sql .= " OR p.title like '%" . $this->params['query'] . "%') ";
$sql .= " AND p.parent_id=0 GROUP BY p.id LIMIT 10";
$secondObs = $db->selectObjectsBySql($sql);
foreach ($secondObs as $set) {
$set->weight = 2;
$res[$set->model] = $set;
}
$sql = "select DISTINCT(p.id) as id, p.title, model, sef_url, f.id as fileid from " . $db->prefix . "product as p INNER JOIN " . $db->prefix . "content_expFiles as cef ON p.id=cef.content_id INNER JOIN " . $db->prefix . "expFiles as f ON cef.expFiles_id = f.id WHERE ";
if (!($user->is_admin || $user->is_acting_admin)) {
$sql .= '(p.active_type=0 OR p.active_type=1) AND ';
}
$sql .= " (p.model like '" . $this->params['query'] . "%' ";
$sql .= " OR p.title like '" . $this->params['query'] . "%') ";
$sql .= " AND p.parent_id=0 GROUP BY p.id LIMIT 10";
$thirdObs = $db->selectObjectsBySql($sql);
foreach ($thirdObs as $set) {
if (strcmp(strtolower(trim($this->params['query'])), strtolower(trim($set->model))) == 0) {
$set->weight = 10;
} else {
if (strcmp(strtolower(trim($this->params['query'])), strtolower(trim($set->title))) == 0) {
$set->weight = 9;
} else {
$set->weight = 3;
}
}
$res[$set->model] = $set;
}
function sortSearch($a, $b)
{
return $a->weight == $b->weight ? 0 : $a->weight < $b->weight ? 1 : -1;
}
if (count($terms)) {
foreach ($res as $r) {
foreach ($terms as $term) {
if (stristr($r->title, $term)) {
$res[$r->model]->weight = $res[$r->model]->weight + 1;
}
}
}
}
usort($res, 'sortSearch');
$ar = new expAjaxReply(200, gt('Here\'s the items you wanted'), $res);
$ar->send();
}
示例3: search
<?php
$page_title = "Search";
$linkno = 0;
include_once 'includes/header.php';
include_once 'classes/search.php';
$searchby = null;
$num_found_rows = 0;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['searchby'])) {
$searchby = $_POST['searchby'];
$objSearch = new search();
$dbRowsSearchResults = $objSearch->getSearchResults($searchby);
$num_found_rows = $dbRowsSearchResults->num_rows;
//echo '<br/><br/><br/><br/><br/><br/>'.$num_rows;
}
}
?>
<!-- Begin page content -->
<div class="container-fluid">
<!-- search by: people, skills, projects -->
<h2 class="page-header"><?php
echo $num_found_rows;
?>
results for <strong><span class="text-success"><?php
echo $searchby;
?>
示例4: searchQueryReport
public function searchQueryReport()
{
global $db;
//Instantiate the search model
$search = new search();
//Store the keywords that returns nothing
$badSearch = array();
$badSearchArr = array();
//User Records Initialization
$all_user = -1;
$anonymous = -2;
$uname = array('id' => array($all_user, $anonymous), 'name' => array('All Users', 'Anonymous'));
$user_default = '';
$where = '';
if (isset($this->params['user_id']) && $this->params['user_id'] != -1) {
$user_default = $this->params['user_id'];
}
expHistory::set('manageable', $this->params);
$ctr = 2;
$ctr2 = 0;
//Getting the search users
$records = $db->selectObjects('search_queries');
foreach ($records as $item) {
$u = user::getUserById($item->user_id);
if ($item->user_id == 0) {
$item->user_id = $anonymous;
}
if (!in_array($item->user_id, $uname['id'])) {
$uname['name'][$ctr] = $u->firstname . ' ' . $u->lastname;
$uname['id'][$ctr] = $item->user_id;
$ctr++;
}
$result = $search->getSearchResults($item->query, true);
if (empty($result) && !in_array($item->query, $badSearchArr)) {
$badSearchArr[] = $item->query;
$badSearch[$ctr2]['query'] = $item->query;
$badSearch[$ctr2]['count'] = $db->countObjects("search_queries", "query='{$item->query}'");
$ctr2++;
}
}
//Check if the user choose from the dropdown
if (!empty($user_default)) {
if ($user_default == $anonymous) {
$u_id = 0;
} else {
$u_id = $user_default;
}
$where .= "user_id = {$u_id}";
}
//Get all the search query records
$records = $db->selectObjects('search_queries', $where);
for ($i = 0; $i < count($records); $i++) {
if (!empty($records[$i]->user_id)) {
$u = user::getUserById($records[$i]->user_id);
$records[$i]->user = $u->firstname . ' ' . $u->lastname;
}
}
$limit = empty($this->config['limit']) ? 10 : $this->config['limit'];
$order = empty($this->config['order']) ? 'timestamp' : $this->config['order'];
$page = new expPaginator(array('records' => $records, 'where' => 1, 'model' => 'search_queries', 'limit' => $limit, 'order' => $order, 'controller' => $this->baseclassname, 'action' => $this->params['action'], 'columns' => array(gt('ID') => 'id', gt('Query') => 'query', gt('Timestamp') => 'timestamp', gt('User') => 'user_id')));
assign_to_template(array('page' => $page, 'users' => $uname, 'user_default' => $user_default, 'badSearch' => $badSearch));
}