ActiveRecord 这个class文件update方法里面如何下:
public function update($runValidation = true, $attributeNames = null)
<code>{ if ($runValidation && !$this->validate($attributeNames)) { Yii::info('Model not updated due to validation error.', __METHOD__); return false; } if (!$this->isTransactional(self::OP_UPDATE)) { return $this->updateInternal($attributeNames); } $transaction = static::getDb()->beginTransaction(); try { $result = $this->updateInternal($attributeNames); if ($result === false) { $transaction->rollBack(); } else { $transaction->commit(); } return $result; } catch (\Exception $e) { $transaction->rollBack(); throw $e; } } </code>
为什么update底层也用了事务操作,如果在外面也开启事务,事务嵌套,会造成什么影响?
ActiveRecord 这个class文件update方法里面如何下:
public function update($runValidation = true, $attributeNames = null)
<code>{ if ($runValidation && !$this->validate($attributeNames)) { Yii::info('Model not updated due to validation error.', __METHOD__); return false; } if (!$this->isTransactional(self::OP_UPDATE)) { return $this->updateInternal($attributeNames); } $transaction = static::getDb()->beginTransaction(); try { $result = $this->updateInternal($attributeNames); if ($result === false) { $transaction->rollBack(); } else { $transaction->commit(); } return $result; } catch (\Exception $e) { $transaction->rollBack(); throw $e; } } </code>
为什么update底层也用了事务操作,如果在外面也开启事务,事务嵌套,会造成什么影响?