Browse Source

Throw warnings if an ORM instance is unable to update/insert a row

Nathaniel van Diepen 6 years ago
parent
commit
6e06fec289
1 changed files with 7 additions and 3 deletions
  1. 7 3
      orm.abstract.class.php

+ 7 - 3
orm.abstract.class.php

@@ -317,11 +317,15 @@
 				$pk = static::primary_key();
 				$table = static::table();
 				if($this->has($pk) && !is_null($this->id) && !in_array($pk, $this->_changed)){
-					$table->update($data, [
+					if($table->update($data, [
 						$pk => $this->id
-					]);
+					]) === 0){
+						trigger_error("Save of {$this->name} may have failed. No affected rows.", E_USER_WARNING);
+					}
 				}else{
-					$table->insert($data);
+					if($table->insert($data) === 0){
+						trigger_error("First save of {$this->name} may have failed. No affected rows.", E_USER_WARNING);
+					}
 					$this->_data[$pk] = self::$pdo->lastInsertId();
 				}
 				foreach($this->_related as $related){