2012-03-23 26 views
16

cakephp'de proje yapıyorum.cakephp'de alana göre sipariş ver

cakephp Style'da aşağıdaki sorguyu yazmak istiyorum. % 50 yazdım. Bana yardım edin

$ this-> Login-> find ('all')

SELECT * FROM login 
ORDER BY FIELD(profile_type, 'Basic', 'Premium') DESC; 

cevap

20

Plese bu

$this->Login->find('all', array(
 'order'=>array('FIELD(Login.profile_type, "basic", "premium") DESC') 
)); 
3

Sen the find method seçenekleri geçirebilirsiniz:

$this->Login->find('all', array(
    'order' => "FIELD(Login.profile_type, 'Basic', 'Premium') DESC" 
)); 
1
deneyin

Lütfen bunu deneyin:

$response = $this->Login->find('all', array('order'=>array('Login.profile_type'=>'desc'))); 
Bu seferki çalışıyor daha kolay sipariş yolu ve sınır
1

olduğunu

$this->set('users', 
    $this->User->find('all', 
     array(
      'limit' => 3, 
      'order' => 'User.created DESC', 
      'recursive' => 1, 
     ) 
    ) 
); 
İlgili konular