在用戶模型數據打印如果我做echo數據。我的問題是如何檢索用戶控制器中的相同數據,我試圖做,但沒有奏效。從模型檢索數據到控制器
user.php的(模型)
function display_children($parent, $level)
{
$result = mysql_query('SELECT title FROM tree '.'WHERE parent="'.$parent.'"');
while ($row = mysql_fetch_array($result))
{
$data = str_repeat(' ',$level).$row['title']."\n";
// echo $data if i remove comment it display all data
// i m getting all data on this variable $data
$this->display_children($row['title'], $level+1);
}
}
users_controller.php中
public function admin_mlm($id){
pr($this->User->display_children('Food',0)); // function argument work but no data printed here
}
在數據庫中是否存在level = 0的一些數據? –
我從用戶控制器傳遞參數,我的數據在模型中正確顯示,我有問題如何在控制器中檢索相同的數據 –
我想知道爲什麼你不使用包裝類(數據源)作爲簡單任務。這畢竟是強大框架的主要優勢之一。 – mark