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)); }
<?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);
public function testLimit() { $query = new Query(); $query->limit(10); $this->assertEquals(10, $query->getLimit()); }
function limit($limit) { $query = new Query(); return $query->limit($limit); }
<?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();
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; }
public function testDeleteStatement_Limit() { $query = new Query("DELETE FROM `test`"); $query->limit(10); $this->assertEquals("DELETE FROM `test` LIMIT 10", (string) $query); }