PHP code example of lsys / search

1. Go to this page and download the library: Download lsys/search library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lsys / search example snippets


//关于 product 参考:dome/Search/Product.php
$ps= new Product();
$res=$ps->query(
		Query::factory("ptitle")->set_page(1)
		->set_highlight(
			Highlight::factory(array("title"))
		)
	);

var_dump($res->get_total());
var_dump($res->get_time());

foreach ($res as $v){
	var_dump($v->pk());
	var_dump($v->get_highlight("title"));
}


//配合Lorm使用,可将搜索结果直接转换为ORM,方便使用
//需先加载 composer w Active("product"));
foreach ($res as $v){
	var_dump($v->get_entity()->pk());
	var_dump($v->get_entity()->asArray());
	var_dump($v->get_highlight("title"));
}