Skip to content

Commit

Permalink
Added a check of the result from the PDOStatement::execute() call in …
Browse files Browse the repository at this point in the history
…the save() function to throw an error containing the PDO Error code in case of a false success.
  • Loading branch information
tomvo committed Jan 15, 2013
1 parent 1b33133 commit 9e1f40a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions idiorm.php
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,11 @@ public function save() {
$statement = self::$_db->prepare($query);
$success = $statement->execute($values);

if($success === false){
$error = $statement->errorInfo();
throw new \PDOException($error[2], $error[1]);
}

// If we've just inserted a new record, set the ID of this object
if ($this->_is_new) {
$this->_is_new = false;
Expand Down

0 comments on commit 9e1f40a

Please sign in to comment.