Node method setDepth has Error on Laravel 5.1.18
I just got this errors.
QueryException in Connection.php line 651: SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. (SQL: ROLLBACK TO SAVEPOINT trans2)
My main code has DB::beginTransaction(); seems cause issue with
DB::beginTransaction();
try{
$model->title = Input::get('title');
$model->slug = Input::get('slug');
$model->description = Input::get('description');
$model->user_id = Auth::user()->id;
$model->save();
DB::commit();
}//try
in Node.php I commented transaction closure on setDepth method and it works.
public function setDepth() {
$self = $this;
//comment the transaction since the main code covered
//$this->getConnection()->transaction(function() use ($self) {
$self->reload();
$level = $self->getLevel();
$self->newNestedSetQuery()->where($self->getKeyName(), '=', $self->getKey())->update(array($self->getDepthColumnName() => $level));
$self->setAttribute($self->getDepthColumnName(), $level);
//});
return $this;
}
Please help to check and update the code.
Notes, It happen every where has the code "getConnection()->transaction" so I comments every where.
Are your database tables engineered with InnoDB? MyISAM tables are not supporting transactions: http://stackoverflow.com/questions/15678406/when-to-use-myisam-and-innodb