2012-01-24 73 views
1

我將CakePHP 1.2站點轉換爲1.3並在幾個問題中運行。由於Model :: findAll在1.3版中已被刪除,因此我如何轉換這段代碼?CakePHP 1.2到1.3 - 轉換findAll

$pages = $this->Page->findAll("category like '{$page['Page']['category']}'",null,'sort_order');

回答

2

它應該更像

$pages = $this->Page->find('all', array(
    'conditions' => array('category LIKE' => $page['Page']['category']), 
    'order'=>array(...), 
    'fields'=>array(...) 
)); 
+0

OK @SoHo投給本評論,他剛剛回答比我快3分鐘:) – flakerimi

+0

我可能會補充說,你應該試着總是以模型爲前綴來避免衝突(現在和以後):'Page.category LIKE' – mark

-1

我覺得是這樣的。

$pages = $this->Page->find('all', array('conditions' => array('category like ' => '{$page['Page']['category']}))); 
+1

這是你的朋友:http://book.cakephp.org/1.3/view/1018/find – flakerimi