Skip to content

Instantly share code, notes, and snippets.

@felipesr
Created August 3, 2014 00:05
Show Gist options
  • Save felipesr/9bd8bdb38fddbac7c4f2 to your computer and use it in GitHub Desktop.
Save felipesr/9bd8bdb38fddbac7c4f2 to your computer and use it in GitHub Desktop.
<?php
class ArtigosController extends AppController {
//public $scaffold;
public $uses = array('Artigo');
public function listar($page) { // Busca todas as notícias
$this->Artigo->page = $page;
$params = array(
'fields' => array('Artigo.nome', 'Artigo.data', 'Artigo.url'),
'order' => array('Artigo.data' => 'DESC'),
'limit' => 10,
'page' => $page
);
$this->paginate = $params;
// Roda a consulta, já trazendo os resultados paginados
$artigos = $this->paginate('Artigo');
//$artigos = $this->Artigo->find('all', $params);
// Manda para a View
$this->set('artigos', $artigos);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment