【发布时间】:2015-08-01 02:45:04
【问题描述】:
这是我在 cakephp 控制器中的函数编辑:
public function edit($id = null) {
if ($this->request->is('get')) {
$this->request->data = $this->Topic->findById($id);
}
...
第一个问题是传递给函数的参数 id 的类型是字符串而不是整数。 其次,在数据库中有一个 id = 14 的主题,这两个代码检索到相同的结果,我不明白为什么:
http://localhost/cakephp1/topics/edit/14
http://localhost/cakephp1/topics/edit/14anyCharactersHere
【问题讨论】: