开发者

CakePHP - get the data from table too

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().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜