|
|
|
@ -667,12 +667,11 @@ class ActiveRecord extends Model
|
|
|
|
|
*/ |
|
|
|
|
public function insert($runValidation = true, $attributes = null) |
|
|
|
|
{ |
|
|
|
|
if ($runValidation && !$this->validate($attributes)) { |
|
|
|
|
if ($runValidation && !$this->validate($attributes) || !$this->beforeSave(true)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if ($this->beforeSave(true)) { |
|
|
|
|
$values = $this->getDirtyAttributes($attributes); |
|
|
|
|
if ($values === array()) { |
|
|
|
|
if (empty($values)) { |
|
|
|
|
foreach ($this->primaryKey() as $key) { |
|
|
|
|
$values[$key] = isset($this->_attributes[$key]) ? $this->_attributes[$key] : null; |
|
|
|
|
} |
|
|
|
@ -696,8 +695,6 @@ class ActiveRecord extends Model
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Saves the changes to this active record into the associated database table. |
|
|
|
@ -750,12 +747,11 @@ class ActiveRecord extends Model
|
|
|
|
|
*/ |
|
|
|
|
public function update($runValidation = true, $attributes = null) |
|
|
|
|
{ |
|
|
|
|
if ($runValidation && !$this->validate($attributes)) { |
|
|
|
|
if ($runValidation && !$this->validate($attributes) || !$this->beforeSave(false)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if ($this->beforeSave(false)) { |
|
|
|
|
$values = $this->getDirtyAttributes($attributes); |
|
|
|
|
if ($values !== array()) { |
|
|
|
|
if (!empty($values)) { |
|
|
|
|
$condition = $this->getOldPrimaryKey(true); |
|
|
|
|
$lock = $this->optimisticLock(); |
|
|
|
|
if ($lock !== null) { |
|
|
|
@ -781,9 +777,6 @@ class ActiveRecord extends Model
|
|
|
|
|
} else { |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|