1. Find Count
public function some_function() {
// ...
$total = $this->Article->find('count');
$pending = $this->Article->find('count', array(
'conditions' => array('Article.status' => 'pending')
));
$authors = $this->Article->User->find('count');
$publishedAuthors = $this->Article->find('count', array(
'fields' => 'DISTINCT Article.user_id',
'conditions' => array('Article.status !=' => 'pending')
));
// ...
}
2. Find first
$wisuda = $this->Wisuda->find('first', array('conditions' => array('Wisuda.id' => $id)));
$this->set('wisuda',$wisuda);
==========================================================
$this->Post->find('all',
array('conditions'=>array('User.id'=>1,
'Post.id'=>'> 50')));
$this->Post->find('all',
array('conditions'=>array('User.id'=>5),
'fields'=>'Post.name',
'order'=>'Post.id ASC',
'limit'=>20,
'recursive'=>0))
3.Find All
public function some_function() {
// ...
$allArticles = $this->Article->find('all');
$pending = $this->Article->find('all', array(
'conditions' => array('Article.status' => 'pending')
));
$allAuthors = $this->Article->User->find('all');
$allPublishedAuthors = $this->Article->User->find('all', array(
'conditions' => array('Article.status !=' => 'pending')
));
// ...
}
untuk menampilkan di ctp bisa menggunakan 2 cara
1. $this->set('wisuda',$wisuda);
2.$this->set(compact('wisuda');
Tidak ada komentar:
Posting Komentar