本文整理汇总了PHP中Pool::none方法的典型用法代码示例。如果您正苦于以下问题:PHP Pool::none方法的具体用法?PHP Pool::none怎么用?PHP Pool::none使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pool
的用法示例。
在下文中一共展示了Pool::none方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$this->set_title('Pools');
$sql_query = Pool::none()->page($this->page_number())->perPage(CONFIG()->pool_index_default_limit);
$order = $this->params()->order ?: 'id';
$search_tokens = array();
if ($this->params()->query) {
$this->set_title($this->params()->query . " - Pools");
// $query = array_map(function($v){return addslashes($v);}, explode($this->params()->query);
// $query = Tokenize.tokenize_with_quotes($this->params[:query] || "")
$query = explode(' ', addslashes($this->params()->query));
foreach ($query as &$token) {
if (preg_match('/^(order|limit|posts):(.+)$/', $token, $m)) {
if ($m[1] == "order") {
$order = $m[2];
} elseif ($m[1] == "limit") {
$sql_query->perPage(min((int) $m[2], 100));
} elseif ($m[1] == "posts") {
Post::generate_sql_range_helper(Tag::parse_helper($m[2]), "post_count", $sql_query);
}
} else {
// # TODO: removing ^\w- from token.
// $token = preg_replace('~[^\w-]~', '', $token);
$search_tokens[] = $token;
}
}
}
if (!empty($search_tokens)) {
// $value_index_query = QueryParser.escape_for_tsquery($search_tokens);
$value_index_query = implode('_', $search_tokens);
if ($value_index_query) {
# If a search keyword contains spaces, then it was quoted in the search query
# and we should only match adjacent words. tsquery won't do this for us; we need
# to filter results where the words aren't adjacent.
#
# This has a side-effect: any stopwords, stemming, parsing, etc. rules performed
# by to_tsquery won't be done here. We need to perform the same processing as
# is used to generate search_index. We don't perform all of the stemming rules, so
# although "jump" may match "jumping", "jump beans" won't match "jumping beans" because
# we'll filter it out.
#
# This also doesn't perform tokenization, so some obscure cases won't match perfectly;
# for example, "abc def" will match "xxxabc def abc" when it probably shouldn't. Doing
# this more correctly requires Postgresql support that doesn't exist right now.
foreach ($query as $q) {
# Don't do this if there are no spaces in the query, so we don't turn off tsquery
# parsing when we don't need to.
// if (!strstr($q, ' ')) continue;
$sql_query->where("(position(LOWER(?) IN LOWER(REPLACE(name, '_', ' '))) > 0 OR position(LOWER(?) IN LOWER(description)) > 0)", $q, $q);
}
}
}
if (empty($order)) {
$order = empty($search_tokens) ? 'date' : 'name';
}
switch ($order) {
case "name":
$sql_query->order("name asc");
break;
case "date":
$sql_query->order("created_at desc");
case "updated":
$sql_query->order("updated_at desc");
break;
case "id":
$sql_query->order("id desc");
break;
default:
$sql_query->order("created_at desc");
break;
}
$this->pools = $sql_query->paginate();
$samples = [];
foreach ($this->pools as $p) {
if (!($post = $p->get_sample())) {
continue;
}
$p_id = (string) $p->id;
$samples[$p_id] = $post;
}
$this->samples = $samples;
$this->respond_to_list('pools');
}