CakePHP:未定义的索引:

时间:2011-04-22 19:57:42

标签: cakephp cakephp-1.3

这里真的很困惑。我一直得到一个未定义的索引。

控制器:

function makemodel($id = null) {
    $this->Make->id = $id;

    $makes = $this->Make->find('all', array(
        'conditions' => array('id' => $id),
        'contain' => array('Makemodel' => array('Road'))
        )
    );

    $this->set(compact('makes'));
}

观点:

我回应道。来自数组应该是正确的$ make ['Make'] ['MakeName']

我也试过$ make ['Make'] [0] ['MakeName']

它声明它在['Make']

有问题

数组:

Array ( [0] => Array ( [Make] => Array ( [id] => 2 [url_make] => ford [MakeName] => Ford [MakeOrigin] => USA [Summary] => )

        [Makemodel] => Array
            (
                [0] => Array
                    (
                        [id] => 2
                        [ModelName] => Focus
                        [make_id] => 2
                        [Road] => Array
                            (
                                [0] => Array
                                    (
                                        [id] => 1
                                        [makemodel_id] => 2
                                        [RoadTypeID] => 1
                                        [name] => Dirt
                                    )

                                [1] => Array
                                    (
                                        [id] => 2
                                        [makemodel_id] => 2
                                        [RoadTypeID] => 2
                                        [name] => Snow
                                    )

                            )

                    )

            )

    )

[Makemodel] => Array ( [0] => Array ( [id] => 2 [ModelName] => Focus [make_id] => 2 [Road] => Array ( [0] => Array ( [id] => 1 [makemodel_id] => 2 [RoadTypeID] => 1 [name] => Dirt ) [1] => Array ( [id] => 2 [makemodel_id] => 2 [RoadTypeID] => 2 [name] => Snow ) ) ) ) )

1 个答案:

答案 0 :(得分:1)

查看数组:

$ make [0] ['Make'] ['id']等。