2012-07-20 59 views
0

如果我在我的控制器中設置Post模型如下;從設置中訪問數據模型蛋糕PHP

$this->Post->id = $id; 

我可以從郵政訪問數據或做我必須進行執行;

 $this->Post->read() 

我想對郵政進行一些進一步的驗證,以確定正在執行的邏輯。

例如如果POST [ 'submitted_by'] = $這個 - > Auth->用戶( '角色')== '管理員')「僞代碼」

回答

0

試試這個代碼:

$data = $this->Post->read(null, $id) 
0

你必須讀取()才能訪問數據。

這是MVC的工作方式(more info there)。

$this->Post->id = $id; 

此代碼修改視圖實例,這就是全部。您需要另一個功能將視圖鏈接到數據庫。