Skip to content

Commit

Permalink
Update ActiveRecord.php
Browse files Browse the repository at this point in the history
  • Loading branch information
viames committed Feb 1, 2023
1 parent d2915a2 commit ed52f03
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/ActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,7 @@ public function areKeysPopulated(): bool {
private static function hasCompoundKey(): bool {

$class = get_called_class();
$res = (is_array($class::TABLE_KEY) and count($class::TABLE_KEY) > 1);
return $res;
return (is_array($class::TABLE_KEY) and count($class::TABLE_KEY) > 1);

}

Expand Down Expand Up @@ -925,9 +924,10 @@ final public function update($properties=NULL): bool {
Logger::event('Updated ' . $class . ' object with ' . $logParam);

// check and update this object in the common cache
if (isset($app->activeRecordCache[$class][(string)$this->getId()])) {
$uniqueId = is_array($this->getId()) ? implode('-', $this->getId()) : (string)$this->getId();
if (isset($app->activeRecordCache[$class][$uniqueId])) {
$app->putActiveRecordCache($class, $this);
Logger::event('Updated ' . $class . ' object with id=' . (string)$this->getId() . ' in common cache');
Logger::event('Updated ' . $class . ' object with id=' . $uniqueId . ' in common cache');
}

// object is not populated
Expand Down Expand Up @@ -956,7 +956,7 @@ final public function updateNotNull(): bool {
$binds = $class::getBinds();
$properties = [];

foreach ($binds as $objProp => $dbField) {
foreach (array_keys($binds) as $objProp) {

if (!is_null($this->$objProp)) {
$properties[] = $objProp;
Expand Down Expand Up @@ -2438,7 +2438,7 @@ public function getForm(): Form {
/**
* Returns unique ID of inherited object or in case of compound key, an indexed array.
*
* @return int|string|array
* @return int|string|array|NULL
*/
final public function getId() {

Expand All @@ -2450,7 +2450,7 @@ final public function getId() {
}
}

return ((static::hasCompoundKey() or !isset($ids[0])) ? $ids : $ids[0]);
return (static::hasCompoundKey() ? $ids : ($ids[0] ?? NULL));

}

Expand Down

0 comments on commit ed52f03

Please sign in to comment.