2012-11-22 70 views
1

我在cakephp代碼中遇到問題,下面的代碼工作正常。CakePHP 2.0分頁訂單子句與FIELD()函數不起作用

$options['conditions'] = array(
     'Tender.archidata_interest !=' => 'Not interesting',    
    );    
    $options['order'] = array(
     "FIELD(Status.flag, 'communication_pending', 'active')" 
    );   
    $archidata_tender = $this->Tender->find('all', $options); 

但蛋糕分頁代碼不適用於訂單子句。

$tender_cond[] = array('Tender.id' => $local_tenders_id); 
$this->paginate = array('page' => '1', 'limit' => $pagelimit, 'order' => array("FIELD(Status.flag, communication_pending, active)"));$this->set('tenders', $this->paginate('Tender', $tender_cond)); 

我使用FIELD(Status.flag,communication_pending活動)根據以下順序,但其沒有工作,也沒有給出任何錯誤得到結果。 需要幫助謝謝

回答

0

'訂單'=> 「FIELD(Status.flag,communication_pending,活性)」 去除陣列的工作對我來說:)

0

這只是你忘了分頁代碼中的引號的問題嗎?嘗試改變此:

'order' => array("FIELD(Status.flag, communication_pending, active)") 

這樣:

'order' => array("FIELD(Status.flag, 'communication_pending', 'active')") 
+1

由於對於你的回覆Bill,它的工作原理是'order'=>「FIELD(Status.flag,communication_pending,active)」,通過移除它的奇怪數組,但在我的情況下工作正常。 – Coder