如果我回显 $data,则在用户模型中打印数据。我的问题是如何在用户控制器中检索相同的数据,我试图这样做,但没有奏效。
用户.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
}