• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Search类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Search的典型用法代码示例。如果您正苦于以下问题:PHP Search类的具体用法?PHP Search怎么用?PHP Search使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: search_query

 public static function search_query($keyword = '', $category = '')
 {
     if (isset($_GET)) {
         $keyword_clean = mysqli_real_escape_string(db_connect(), $keyword);
         $category_clean = mysqli_real_escape_string(db_connect(), $category);
         if ($category_clean === 'post') {
             $search_results = db_select("SELECT * FROM post WHERE title LIKE '%" . $keyword_clean . "%' OR body LIKE '%" . $keyword_clean . "%'");
         } elseif ($category_clean === 'category') {
             $search_results = db_select("SELECT * FROM category WHERE title LIKE '%" . $keyword_clean . "%' OR description LIKE '%" . $keyword_clean . "%'");
         } elseif ($category_clean === 'page') {
             $search_results = db_select("SELECT * FROM page WHERE title LIKE '%" . $keyword_clean . "%' OR body LIKE '%" . $keyword_clean . "%'");
         } elseif ($category_clean === 'upload') {
             $search_results = db_select("SELECT * FROM upload WHERE filename LIKE '%" . $keyword_clean . "%' OR filetype LIKE '%" . $keyword_clean . "%' OR filepath LIKE '%" . $keyword_clean . "%'");
         } elseif ($category_clean === 'user') {
             $search_results = db_select("SELECT * FROM user WHERE username LIKE '%" . $keyword_clean . "%'");
         } else {
             // ALL
             $search = new Search();
             $search_results = $search->searchAllDB($keyword_clean);
             //print_r($search_results);
         }
     } else {
         $search_results = '';
         $flash = new Flash();
         $flash->flash('flash_message', 'No keyword entered!', 'danger');
     }
     return $search_results;
 }
开发者ID:gwhitcher,项目名称:gwpress,代码行数:28,代码来源:search.php


示例2: index

 function index()
 {
     $q = trim(Input::get('q'));
     if (empty($q) || !Input::has('q')) {
         return Redirect::home();
     }
     if (!Input::has('guess') || Input::get('guess') != 'no') {
         $regex = array('pilot' => '[0-9]+', 'airport' => '[A-Z0-9]{4}', 'airline' => '[A-Z0-9]{3}', 'airportIata' => '[A-Z0-9]{3}', 'citypair' => '([A-Z0-9]{3,4})(?:(?:\\s*?[-|>]\\s*?)|\\s+to\\s+|\\s+)([A-Z0-9]{3,4})', 'callsign' => '.*');
         $search = new Search($q);
         foreach ($regex as $type => $pattern) {
             if (preg_match('/^' . $pattern . '$/i', $q, $matches) && ($match = $search->quick($type, $matches))) {
                 Messages::info('You were redirected here by a best guess of the search system. <a href="' . URL::route('search', array('q' => $q, 'guess' => 'no')) . '" class="alert-link">Return to search results.</a>');
                 return $match;
             }
         }
     }
     $pilots = Pilot::where(function ($search) use($q) {
         $search->where('vatsim_id', '=', $q);
         $search->orWhere(function ($name) use($q) {
             $name->where('name', 'LIKE', '%' . $q . '%');
             $name->where('anonymous', '=', false);
         });
     })->where('vatsim_id', '!=', 0)->get();
     $flights = Flight::where('callsign', '=', $q)->orderBy('departure_time', 'desc')->get();
     $airlines = Airline::where('icao', '=', $q)->orWhere('name', 'LIKE', '%' . $q . '%')->get();
     $airports = Airport::where('icao', '=', $q)->orWhere('iata', '=', $q)->orWhere('name', 'LIKE', '%' . $q . '%')->orWhere('city', 'LIKE', '%' . $q . '%')->get();
     $this->autoRender(compact('q', 'flights', 'pilots', 'airlines', 'airports'), 'Search');
 }
开发者ID:T-SummerStudent,项目名称:new,代码行数:28,代码来源:SearchController.php


示例3: view

 public function view()
 {
     $dao = DAO::getDAO('SearchDAO');
     if (isset($this->params[0]) && trim($this->params[0]) == 'remove') {
         // ex: requesting: /search/delete/2
         $id = trim(sanitizeString($this->params[1]));
         $dao->removeById($id);
     } else {
         if (isset($this->params[0]) && trim($this->params[0]) == 'add') {
             $randNum = mt_rand(0, 99999);
             $newSearch = new Search(array('username' => "test{$randNum}", 'email' => "test{$randNum}@example.com", 'created' => dbDateTime()));
             // #TODO: implement UserDao.create($newUser) instead.
             if ($dao->countAll() > 30) {
                 // Demo mode: clean up if too many searchs
                 $dao->execute("DELETE FROM searchs");
                 $dao->execute("vacuum");
             }
             $dao->insertInto("username, email, created", $newSearch->getFields());
         }
     }
     $search = $dao->getAll();
     $v = $this->smarty;
     $v->assign('title', 'Search List');
     $v->assign('inc_content', v('search.html'));
     $v->assign('search', $search);
     $v->assign('totalSearch', $dao->countAll());
     $this->display($v, v('index.html'));
 }
开发者ID:renduples,项目名称:alibtob,代码行数:28,代码来源:Search.php


示例4: testShouldGenerateSearchStringArray

 public function testShouldGenerateSearchStringArray()
 {
     $params = array('CISOROOT' => 'all', 'CISOOP1' => 'any', 'CISOFIELD1' => 'creato', 'CISOBOX1' => 'michigan lake', 'CISOOP2' => 'all', 'CISOFIELD2' => 'title', 'CISOBOX2' => 'general grant', 'media-types' => array('image', 'audio', 'map', 'docs'), 'search-button.x' => '61', 'search-button.y' => '19', 'search-button' => '');
     $search = new Search();
     $search->set_search_string($params);
     $this->assertEquals('creato', $search->search_string[0]['field']);
 }
开发者ID:JillArnold,项目名称:dnr-ContentDM,代码行数:7,代码来源:SearchSetSearchStringTest.php


示例5: indexAction

 public function indexAction()
 {
     $key = $this->getRequest()->get('kw');
     $orderby = $this->getRequest()->get('od');
     $page = $this->getRequest()->get('page', 1);
     // $router = \Yaf\Dispatcher::getInstance()->getRouter();
     // $config = \Yaf\Application::app()->getConfig();
     $search = new Search();
     $search->setQ($key);
     $search->setPage($page);
     if (!empty($orderby)) {
         $search->setSortby($orderby);
     }
     $res = $search->query();
     $pages = 1;
     $films = null;
     if ($res) {
         $pages = empty($res['pages']) ? 1 : $res['pages'];
         if (isset($res['matches'])) {
             foreach ($res['matches'] as $match) {
                 $ids[] = $match['id'];
             }
             $conn = new MyPDO();
             $films = $conn->table('film')->select('*')->where('id in (' . implode(',', $ids) . ')')->orderBy('order by find_in_set (id, \'' . implode(',', $ids) . '\')')->execute();
         }
     }
     $this->_view->assign('films', $films);
     $this->_view->assign('kw', $key);
     $this->_view->assign('orderby', $orderby);
     $this->_view->assign('page', $page);
     $this->_view->assign('pages', $pages);
 }
开发者ID:RaiseFree,项目名称:btsousuo,代码行数:32,代码来源:Search.php


示例6: show

 private function show($q)
 {
     include 'lib/search.php';
     $search = new Search();
     $items = $search->do_search($q);
     foreach ($items as $item) {
         $item->content = process_content($item->content);
         foreach ($item->comments as $comment) {
             $comment->content = process_content($comment->content);
         }
         foreach ($item->likes as $like) {
             if (isset($_SESSION['user_id']) && $like->user_id == $_SESSION['user_id']) {
                 $item->i_like = true;
             } else {
                 $item->i_like = false;
             }
         }
     }
     if (isset($this->plugins->log)) {
         $result_count = count($items);
         $this->plugins->log->add($_SESSION['user_id'], 'search', NULL, 'new', "Term = {$q}\nResult_count = {$result_count}");
     }
     if ($this->json) {
         $this->render_json($items);
     } else {
         $this->loadView('search/index', array('items' => $items));
     }
 }
开发者ID:Geekathon,项目名称:rat,代码行数:28,代码来源:search_controller.php


示例7: getBookSearchResults

 public function getBookSearchResults()
 {
     $search = new Search();
     $books = $search->searchBook($_POST['searchstring']);
     include 'view/libro/search_menu.php';
     include 'view/libro/libros.php';
 }
开发者ID:apexJCL,项目名称:mvc,代码行数:7,代码来源:search.php


示例8: get_top_recommendations

 public function get_top_recommendations($query_name, $number)
 {
     $auth = Clarifai::get_auth($this->client_id, $this->client_secret);
     $matches = $this->get_initial_recommendations($query_name, $number);
     // Get initial recommended movies
     $number = count($matches);
     if ($number <= 0) {
         return NULL;
     }
     $query = new Search($query_name);
     $query_links = $query->get_links();
     // Get links to query stills using Google Images API
     $links = array();
     $links[$query_name] = $query_links;
     // Array containing links
     foreach ($matches as $match) {
         // Get stills to each of the initial recommended movies
         $match_search = new Search($match);
         $links[$match] = $match_search->get_links();
         // Add links to array
     }
     $tags_array = Clarifai::get_unique_tags($links, $auth);
     // Get tags using Clarifai API
     $results = array();
     foreach (array_slice($tags_array, 1, $number) as $key => $tags) {
         $results[$key] = count(array_intersect($tags, $tags_array[$query_name]));
     }
     arsort($results);
     return array_keys($results);
 }
开发者ID:edwardshe,项目名称:Cinemaku,代码行数:30,代码来源:Recommender.php


示例9: testAnnotations

 public function testAnnotations()
 {
     $s = new Search('reddress');
     $s->setUid('b1cb66795dfb0ff41fff56c841c0dea8');
     $s->setTqid('D9XmaeqdjAxrkDPX');
     $this->assertEquals('q=reddress&tqid=D9XmaeqdjAxrkDPX&uid=b1cb66795dfb0ff41fff56c841c0dea8', $s->getUrlString());
 }
开发者ID:blackbirdtech,项目名称:merlin-php,代码行数:7,代码来源:OtherTests.php


示例10: getUserLabels

 /**
  * getUserLabels Helper
  *
  * @param     array $data
  * @param     function $callback
  * @return    mixed
  */
 static function getUserLabels(array $data, $callback = false)
 {
     // validate data parameters
     if (!isset($data['website'])) {
         throw new \InvalidArgumentException('website is required.');
     }
     // validate data parameters
     if (!isset($data['search'])) {
         throw new \InvalidArgumentException('search is required.');
     }
     $woopra_labels = Woopra::getAllLabels($data);
     $search = new Search($data);
     $rsp = $search->search(array('website' => $data['website'], 'search' => $data['search']));
     $labels = array();
     foreach ($rsp->visitors as $visitor) {
         foreach ($visitor->labels as $label) {
             if (array_key_exists($label, $woopra_labels)) {
                 $labels[$label] = $woopra_labels[$label];
             }
         }
     }
     // run callback or return the label data
     if (is_callable($callback)) {
         $callback($labels);
     } else {
         return $labels;
     }
 }
开发者ID:aamortimer,项目名称:woopra,代码行数:35,代码来源:Woopra.php


示例11: searchPostAction

 public function searchPostAction($search)
 {
     $admin = new Search();
     $searchResult = $admin->setSearchItem($_GET['search'], 'posts');
     require_once ROOT_PATH . DIRECTORY_SEPARATOR . 'templates/front/header.php';
     require_once ROOT_PATH . DIRECTORY_SEPARATOR . 'templates/front/search.php';
     require_once ROOT_PATH . DIRECTORY_SEPARATOR . 'templates/front/footer.php';
 }
开发者ID:devM4x,项目名称:board_php,代码行数:8,代码来源:frontController.php


示例12: testFiter

 public function testFiter()
 {
     $s = new Search('');
     $s->addFilter((new Filter('tags', '=', 'Women'))->addOr('tags', '=', 'dress pants'));
     $r = $this->engine->search($s);
     $this->assertEquals($r->results->hits[0]->id, 'f346904e7dcd43c521bff2e6dcfae21a');
     $this->assertEquals($r->results->hits[1]->id, 'c05ef333b5dbd9f31123a65221762395');
 }
开发者ID:blackbirdtech,项目名称:merlin-php,代码行数:8,代码来源:MerlinTest.php


示例13: solrSearch

 /**
  * Search with solr & prepare data for output
  *
  * @param $p options
  * @param $prepare bool
  */
 private function solrSearch($p, $prepare = false)
 {
     // skip grid params
     unset($p->grid);
     $p->fl = 'id, pid, path, name, template_type, system, ' . 'size, date, date_end, oid, cid, cdate, uid, udate, case_id, acl_count, ' . 'case, template_id, task_u_assignee, status, task_d_closed, versions, ' . 'case_violation_resolved, case_violation_unresolved, cfg, type, nid, ' . 'search_hash, case_hash';
     $s = new Search();
     return $s->query($p);
 }
开发者ID:austinvernsonger,项目名称:casebox,代码行数:14,代码来源:Instance.php


示例14: Search

 public function Search($param)
 {
     //echo "hello";
     import('SC.Search.Search');
     $searchInfo = new Search($param);
     $result = $searchInfo->run();
     echo $result;
 }
开发者ID:iOSDevelopment2016,项目名称:SuperCourseServer,代码行数:8,代码来源:Api.class.php


示例15: before_render

 public function before_render(&$template, &$content)
 {
     parent::before_render($template, $content);
     /*
      * Create the browser title.
      */
     if (strlen($content->get('browser_title')) === 0) {
         if (strlen($content->get('page_title')) > 0) {
             $content->set('browser_title', $content->get('page_title'));
             $content->append('browser_title', ' - ' . SITE_TITLE);
         } else {
             $content->set('browser_title', SITE_TITLE);
         }
     } else {
         $content->append('browser_title', '&#8202;-&#8202;' . SITE_TITLE);
     }
     /*
      * Include the place name (e.g., "Washington," "Texas," "United States").
      */
     $content->set('place_name', PLACE_NAME);
     /*
      * Get the edition data
      */
     $search = new Search();
     // Since we don't have any conditions in our template, we have to build
     // html here.
     if (!$content->is_set('current_edition') && defined('EDITION_ID')) {
         $content->set('current_edition', EDITION_ID);
     }
     $content->set('edition_select', $search->build_edition($content->get('current_edition')));
     /*
      * Set our search terms.
      */
     $query = '';
     if (isset($_GET['q'])) {
         $query = $_GET['q'];
     }
     $content->set('search_terms', $query);
     /*
      * If a Google Analytics Web Property ID has been provided, insert the tracking code.
      */
     if (defined('GOOGLE_ANALYTICS_ID')) {
         $content->prepend('javascript', "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n\t\t\t\t(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n\t\t\t\tm=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n\t\t\t\t})(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\n\t\t\t\tga('create', '" . GOOGLE_ANALYTICS_ID . "', 'auto');\n\t\t\t\tga('send', 'pageview');");
     }
     /*
      * If a Typekit ID has been provided, insert the JavaScript.
      */
     if (defined('TYPEKIT_ID')) {
         $this->add_asset('typekit_js', array('path' => '//use.typekit.net/' . TYPEKIT_ID . '.js', 'type' => 'javascript'));
         $content->append('javascript', 'try{Typekit.load();}catch(e){};');
     }
     $content->append('javascript', 'var zclip_swf_file = "' . THEME_WEB_PATH . 'static/js/vendor/ZeroClipboard.swf";');
     /*
      * Setup assets
      */
     $this->render_assets($template, $content);
 }
开发者ID:CodeforHawaii,项目名称:statedecoded,代码行数:57,代码来源:class.Page.inc.php


示例16: testShouldCreateSearchTerms

 public function testShouldCreateSearchTerms()
 {
     $search = new Search();
     $search->media_types = array('image', 'audio', 'video', 'docs');
     $search->generate_content_type_search_string();
     $this->assertEquals('format', $search->search_string[0]['field']);
     $this->assertEquals('image audio video Document ', $search->search_string[0]['string']);
     $this->assertEquals('all', $search->search_string[0]['mode']);
 }
开发者ID:JillArnold,项目名称:dnr-ContentDM,代码行数:9,代码来源:SearchGenerateContentTypeSearchStringTest.php


示例17: testResultsShouldReturnListOfItems

 public function testResultsShouldReturnListOfItems()
 {
     $search = new Search();
     $list = $search->results();
     $this->assertEquals(3, count($list));
     foreach ($list as $item) {
         $this->assertEquals('Item', get_class($item));
     }
 }
开发者ID:JillArnold,项目名称:dnr-ContentDM,代码行数:9,代码来源:search_test.php


示例18: save

 public function save($key_id)
 {
     $db = new PHPWS_DB('ps_text');
     $result = $db->saveObject($this);
     if (PHPWS_Error::isError($result)) {
         return $result;
     }
     $search = new Search($key_id);
     $search->addKeywords($this->content);
     return $search->save();
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:11,代码来源:PS_Text.php


示例19: get

 function get()
 {
     $profile_uid = intval($_GET['p']);
     if (!$profile_uid) {
         $profile_uid = -1;
     }
     $load = argc() > 1 && argv(1) == 'load' ? 1 : 0;
     header("Content-type: text/html");
     echo "<!DOCTYPE html><html><body>\r\n";
     /**
      * We can remove this hack once Internet Explorer recognises HTML5 natively
      */
     echo $_GET['msie'] == 1 ? '<div>' : '<section>';
     /**
      *
      * Grab the page inner contents by calling the content function from the profile module directly, 
      * but move any image src attributes to another attribute name. This is because 
      * some browsers will prefetch all the images for the page even if we don't need them.
      * The only ones we need to fetch are those for new page additions, which we'll discover
      * on the client side and then swap the image back.
      *
      */
     $mod = new Search();
     $text = $mod->get($profile_uid, $load);
     $pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
     $replace = "<img\${1} dst=\"\${2}\"";
     //	$text = preg_replace($pattern, $replace, $text);
     /*
     	if(! $load) {
     		$replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />';
     		$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
     		$text = preg_replace($pattern, $replace, $text);
     		$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
     		$text = preg_replace($pattern, $replace, $text);
     		$pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
     		$text = preg_replace($pattern, $replace, $text);
         	$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
         	$text = preg_replace($pattern, $replace, $text);
     	}
     */
     /**
      * reportedly some versions of MSIE don't handle tabs in XMLHttpRequest documents very well
      */
     echo str_replace("\t", '       ', $text);
     echo $_GET['msie'] == 1 ? '</div>' : '</section>';
     echo "</body></html>\r\n";
     killme();
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:48,代码来源:Update_search.php


示例20: on_get

 private function on_get()
 {
     $response = [];
     foreach (['langs', 'options', 'types'] as $name) {
         if ($this->request->query_boolean($name, false)) {
             $methodname = 'get_' . $name;
             $response[$name] = $this->context->{$methodname}();
         }
     }
     if ($this->request->query_boolean('setup', false)) {
         $response['setup'] = $this->setup->to_jsono($this->context->is_admin());
     }
     if ($this->request->query_boolean('theme', false)) {
         $theme = new Theme($this->context);
         $response['theme'] = $theme->get_icons();
     }
     if ($this->request->query('items', false)) {
         $href = $this->request->query('items.href');
         $what = $this->request->query_numeric('items.what');
         $response['items'] = $this->context->get_items($href, $what);
     }
     if ($this->request->query('custom', false)) {
         Util::json_fail(Util::ERR_DISABLED, 'custom disabled', !$this->context->query_option('custom.enabled', false));
         $href = $this->request->query('custom');
         $custom = new Custom($this->context);
         $response['custom'] = $custom->get_customizations($href);
     }
     if ($this->request->query('l10n', false)) {
         Util::json_fail(Util::ERR_DISABLED, 'l10n disabled', !$this->context->query_option('l10n.enabled', false));
         $iso_codes = $this->request->query_array('l10n');
         $iso_codes = array_filter($iso_codes);
         $response['l10n'] = $this->context->get_l10n($iso_codes);
     }
     if ($this->request->query('search', false)) {
         Util::json_fail(Util::ERR_DISABLED, 'search disabled', !$this->context->query_option('search.enabled', false));
         $href = $this->request->query('search.href');
         $pattern = $this->request->query('search.pattern');
         $search = new Search($this->context);
         $response['search'] = $search->get_items($href, $pattern);
     }
     if ($this->request->query('thumbs', false)) {
         Util::json_fail(Util::ERR_DISABLED, 'thumbnails disabled', !$this->context->query_option('thumbnails.enabled', false));
         Util::json_fail(Util::ERR_UNSUPPORTED, 'thumbnails not supported', !$this->setup->get('HAS_PHP_JPEG'));
         $thumbs = $this->request->query_array('thumbs');
         $response['thumbs'] = $this->context->get_thumbs($thumbs);
     }
     Util::json_exit($response);
 }
开发者ID:Txuritan,项目名称:h5ai,代码行数:48,代码来源:class-api.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP SearchEngine类代码示例发布时间:2022-05-23
下一篇:
PHP ScoreDisplay类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap