Ghufron Asadly. Diberdayakan oleh Blogger.

membuat kondisi di cakephp 2

Minggu, 27 April 2014

membuat suatu kondisi where di cakephp yaitu dengan cara di controller misalnya contoh seperti ini
:

public function penonton() {
$penontons = $this -> Tiket -> find('all', array('conditions' => array('Tiket.status' => 'lunas')));
//                print_r($penontons);
$this -> set('tiket', $this -> paginate());
$this -> set(compact('penontons'));
//                        print_r($users);
}
$this->Post->find('all', 
                   array('conditions'=>array('User.id'=>1, 
                                             'Post.id'=>'> 50')));
# TODO - i'm not sure that this is right; i think 'fields' is supposed to be an array
$this->Post->find('all',
                  array('conditions'=>array('User.id'=>5),
                        'fields'=>'Post.name',
                        'order'=>'Post.id ASC',
                        'limit'=>20,
                        'recursive'=>0));


$posts = $this->Post('all', array( 'conditions' => array('OR' => array('Post.status' => 1, 'Post.type' => 2) )  ) );
'conditions' => array('Post.id >' => 20 ,'OR' => array('Post.status' => 1, 'Post.type' => 2) )
$posts = $this->Post('all', array( 'conditions' => array('OR' => array(array( 'Post.status' => 1), array( 'Post.status' => 2) ) )  ) );

Tidak ada komentar:

Posting Komentar

 

Most Reading