Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy at any search keyword all time appears pagination?
    text
    copied!<p>I created pagination for my search page. Controller - </p> <pre><code>public function action_index() { if(!empty($_GET['search'])){ $pagination= Pagination::factory(array( 'total_items' =&gt; Model::factory('index')-&gt;get_count(), 'items_per_page' =&gt; 2, )); $this-&gt;template-&gt;content = View::factory('index/query') -&gt;set('query', Model::factory('index')-&gt;get_articles_from_query($_GET['search'], $pagination-&gt;offset, $pagination-&gt;items_per_page)) -&gt;set('pagination', $pagination-&gt;render()); } else{ $this-&gt;template-&gt;content = View::factory('index/error')-&gt;set('message', 'Nav rakstu ar šādu atslēgvārdu.'); } } </code></pre> <p>View -</p> <pre><code> &lt;?php foreach ($query as $item): echo '&lt;h2&gt;&lt;a href="/article/' . $item['slug'] . '"&gt;' . $item['virsraksts'] . '&lt;/a&gt;&lt;/h2&gt;'; echo '&lt;p&gt;' . nl2br($item['saturs']) . '&lt;/p&gt;'; endforeach; endif; echo $pagination; ?&gt; </code></pre> <p>Model - </p> <pre><code> public function get_articles_from_query($squery, $offset, $limit){ $query = DB::query(Database::SELECT, 'SELECT * FROM ieraksti WHERE virsraksts like :squery OR slug like :squery OR saturs like :squery ORDER By id DESC LIMIT :offset, :limit ') -&gt;parameters(array(':squery' =&gt; "%$squery%", ':offset' =&gt; $offset, ':limit' =&gt; $limit))-&gt;execute()-&gt;as_array(); return $query; } </code></pre> <p>The pagination appears all time. I want to pagination, when articles found over 2. Where is the mistake? What is the mistake?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload