CakePHP:使用查找和可容纳的未定义变量
遇到另一个问题,我似乎无法找到可能导致的任何信息。
我正在声明变量 $makes ,但在视图中找不到它。
这是我当前的代码:
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->('makes',$this->Make->find(script here));
任何建议将不胜感激谢谢!
除了cakePHP的书之外还有其他参考资料吗?
大批 ( [0] =>大批 ( [制作] =>大批 ( [id] => 1 [url_make] =>斯巴鲁 [品牌名称] =>斯巴鲁 [MakeOrigin] =>日本 【总结】=>
)
[Makemodel] => Array
(
[0] => Array
(
[id] => 1
[ModelName] => Impreza WRX
[make_id] => 1
[Road] => Array
(
[0] => Array
(
[id] => 3
[makemodel_id] => 1
[RoadTypeID] => 1
[name] => Dirt
)
[1] => Array
(
[id] => 4
[makemodel_id] => 1
[RoadTypeID] => 2
[name] => Snow
)
)
)
)
)
)
Running into another issue that I just seem cant to find any information what could be causing.
I am declaring variable $makes and inside the view its not finding it.
here is my current code:
function makemodel($id = null) {
$this->Make->id = $id;
$makes = $this->Make->find('all', array(
'conditions' => array('id' => $id),
'contain' => array('Makemodel' => array('Road'))
)
);
}
}
?>
I have also tried this: $this->set->('makes',$this->Make->find(script here));
Any advice would be appreciated thanks!
Are there any reference material other than cakePHP's book?
Array
(
[0] => Array
(
[Make] => Array
(
[id] => 1
[url_make] => subaru
[MakeName] => Subaru
[MakeOrigin] => Japan
[Summary] =>
)
[Makemodel] => Array
(
[0] => Array
(
[id] => 1
[ModelName] => Impreza WRX
[make_id] => 1
[Road] => Array
(
[0] => Array
(
[id] => 3
[makemodel_id] => 1
[RoadTypeID] => 1
[name] => Dirt
)
[1] => Array
(
[id] => 4
[makemodel_id] => 1
[RoadTypeID] => 2
[name] => Snow
)
)
)
)
)
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
假设 find 调用正常工作,您必须使用
set()
方法将数据从控制器传递到视图。Assuming that the find call is working correctly, you have to pass the data from your controller to your view using the
set()
method.find
返回正确的结果吗?Is
find
returning correct results?