The function below returns an array with the name of the fields, but I also want to include the data that's in the fields.
How would I do that? I am a newbie to CakePHP.
开发者_运维百科function init_form($models)
{
foreach($models as $model=> $value)
{
$this->model = new $value;
$columns = $this->model->schema();
//Extract field names from array
$j = 0;
foreach($columns as $col => $val) {
$arr[$value][$j] = $col;
$j++;
}
if(!empty($model))
{
$arr['associated_table'][$value]=$model;
}
}
return $arr;
}
FYI: I am trying to follow this tutorial http://bakery.cakephp.org/articles/Gkelly/2006/11/09/report-creator-component
I got it to display the fields name. I am just unable to get the data out.
Thanks
Check out the find()
method for retrieving data from your Model.
I am not familiar with the Component you are using. However, considering you have access to the Model with $this->model
, you can use it's find()
method just as you are schema()
- $this->model->find()
.
精彩评论