【发布时间】:2011-11-10 16:41:13
【问题描述】:
我使用最新的代码点火器 (2.0.3) 和 php-active 0.0.1。
除了save()之外,其他都工作正常;
代码:
if($_POST)
{
$entry= Customers::find_by_routeid('4');
$entry->routeid=5;
$entry->save();
}
这是我的问题:由于某种我无法理解的原因,上面的代码不起作用,但是如果我将代码从if ($_POST) 中取出,它就可以正常工作。
我做错了什么?
编辑:
感谢 Damien Pirsy $this->input->post() 解决了这个问题,但是当我取消注释代码中的 cmets 时,问题又回来了。
现在的代码是:
if($this->input->post())
{
$id = $this->input->post('id');
$oldRoute = $this->input->post('oldRoute');
$newRoute = $this->input->post('newRoute');
$entry= Customers::find_by_routeid($this->input->post('oldRoute'));
$entry->routeid=$this->input->post('newRoute');
$entry->save();
/*
if($oldRoute<$newRoute)
{
for ($i=$newRoute; $i>$oldRoute; $i--)
{
$element = Customers::find_by_routeid($i);
echo $element->routeid -= 1;
$element->save();
}
}
*/
}
元素新 ID ($element->routeid -= 1;) 是 echoing 对,但我遇到了与开始时相同的问题,两个保存都没有工作。
【问题讨论】:
标签: php codeigniter activerecord save