Skip to content

Commit

Permalink
Update ActiveRecord.php
Browse files Browse the repository at this point in the history
  • Loading branch information
viames committed Apr 20, 2023
1 parent 7cd29e3 commit e9bd2fc
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/ActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,12 @@ final public function create(): bool {
$dbObj = $this->prepareData($props);
$res = $this->db->insertObject(static::TABLE_NAME, $dbObj, static::getEncryptableFields());

if (!$res) {
Logger::event('Failed to create a new ' . $class . ' object');
$this->addError($this->db->getLastError());
return FALSE;
}

// get last insert id if not compound key
if (!static::hasCompoundKey() and $autoIncrement) {

Expand Down Expand Up @@ -854,7 +860,7 @@ final public function create(): bool {
// hook for tasks to be executed after creation
$this->afterCreate();

return (bool)$res;
return $res;

}

Expand Down Expand Up @@ -924,6 +930,12 @@ final public function update($properties=NULL): bool {

$res = (bool)$this->db->updateObject($class::TABLE_NAME, $dbObj, $dbKey, static::getEncryptableFields());

if (!$res) {
Logger::event('Failed to update ' . $class . ' object');
$this->addError($this->db->getLastError());
return FALSE;
}

// reset updated-properties tracker
$this->updatedProperties = [];

Expand Down

0 comments on commit e9bd2fc

Please sign in to comment.