我有表喜欢系统(喜欢,不喜欢);我想插入或更新新行,但是在save()方法上,我捕获到异常:
Maximum function nesting level of '250' reached, aborting!
有代码:
$liking = Liking::firstOrNew(array('post_id' => $id, 'ip' => Request::ip()));
$liking->like = Input::get('liking') == 'like' ? 1 : 0;
$liking->save();
喜欢的模型代码:
<?php
class Liking extends Eloquent{
protected $table = 'post_liking';
protected $primaryKey = null;
public $timestamps = null;
public $incremeting = false;
}
我试图设置25000个以上的xdebug嵌套级别,但这对我没有帮助
如果您的模型中没有主键,那么雄辩者可能会感到沮丧。尝试在其中添加一id
列post_liking
(即使您不使用它),然后从模型中删除protected $primaryKey = null;
和public $incremeting = false;
行Liking
。
(如果您将id
列手动添加到表中,而不是在migration
using中添加$table->increments('id');
,请确保将其设置为unsigned
整数。)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句