Skip to content

Commit 6f4ad3c

Browse files
committed
Merge pull request #7 from dieend/patch-1
Return false when fails to insert new record
2 parents e0695e3 + ed5c4e1 commit 6f4ad3c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ActiveRecord.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,13 @@ public function insert($runValidation = true, $attributes = null) {
115115
}
116116
$values = $this->getDirtyAttributes($attributes);
117117

118-
$this->getDb()->createCommand()->insert($this->tableName(), $values);
118+
$ret = $this->getDb()->createCommand()->insert($this->tableName(), $values);
119119

120120
$changedAttributes = array_fill_keys(array_keys($values), null);
121121
$this->setOldAttributes($values);
122122
$this->afterSave(true, $changedAttributes);
123123

124-
return true;
124+
return $ret;
125125
}
126126
/**
127127
* Returns the primary key **name(s)** for this AR class.

0 commit comments

Comments
 (0)