1
我是cakephp的新手。我試圖在獲取模型中的結果部分並在回調中使用它後進行查詢。但是,得到錯誤,當我嘗試從模型得到$ newArray的調試。在我的控制器我有這個cakephp如何使用回撥方法
function index($var = null){
if (empty($this->data)) {
}
else {
$results = array();
$getRecords = $this->Model->find('all');
$results = $this->Model->afterFind($getRecords);
debug($this->newArray);
}
}
在我的模型我有這個
class Model extends AppModel {
function afterFind($getRecords){
$newArray = array();
$query_string = $getRecords['Record']['column1']" ;
$results = $this->Model->query($query_string);
foreach($results as $result){
//do something and add to $newArray
}
return $newArray;
}
}