本文整理汇总了PHP中Query::limit方法的典型用法代码示例。如果您正苦于以下问题:PHP Query::limit方法的具体用法?PHP Query::limit怎么用?PHP Query::limit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Query
的用法示例。
在下文中一共展示了Query::limit方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$query = new Query();
$query->orderBy('id', 'DESC');
$query->limit(4);
$posts = $query->find('Posts');
$this->render('index.html.twig', array('posts' => $posts));
}
示例2: Query
<?php
include 'swish.php';
// Get the top results
$s = new Query('../index/main_index.index');
$s->term('xtodayx');
$s->limit(100);
$s->filter('tag_id', 1, 1);
$s->get_hits();
$s->get_results();
$current = $s->serps;
print_r($current);
示例3: testLimit
public function testLimit()
{
$query = new Query();
$query->limit(10);
$this->assertEquals(10, $query->getLimit());
}
示例4: limit
function limit($limit)
{
$query = new Query();
return $query->limit($limit);
}
示例5: Query
<?php
require_once 'autoloader.php';
$query = new Query();
$query->orderBy('id', 'DESC');
$query->limit(2, 4);
$user = $query->isEntity('Users');
var_dump($user);
$user = new Users();
$user->setPseudo('Luke Skywalker');
$user->setAge('26');
$user->setPassword('LoveMySister');
$user->save();
示例6: prepare
public function prepare(Query $query)
{
$newQuery = clone $query;
$this->recordCount = $newQuery->count();
$this->total = intval($this->recordCount / $this->size);
if ($this->recordCount % $this->size > 0) {
$this->total += 1;
}
$current = $this->current;
if ($current === false) {
if (empty($this->field)) {
$current = 1;
} else {
$current = $_GET[$this->field] ?? 1;
}
}
if (!is_numeric($current) || $current <= 0) {
$current = 1;
} elseif ($current >= $this->total) {
$current = $this->total;
}
$this->setCurrent($current);
$query->limit($this->size)->offset(($this->current - 1) * $this->size);
return $this;
}
示例7: testDeleteStatement_Limit
public function testDeleteStatement_Limit()
{
$query = new Query("DELETE FROM `test`");
$query->limit(10);
$this->assertEquals("DELETE FROM `test` LIMIT 10", (string) $query);
}