- Changed returned object from PdoObject runQuery method correcting 'Creation of dynamic property PDOStatement:: is deprecated'

This commit is contained in:
Dave Mc Nicoll committed 2023-04-13 15:39:16 -04:00
1 parent 3c5aa51850
commit f3712c9cc7
6 files changed
+27 -24

No files matched your search

+8 -8
View File
@@ -51,7 +51,7 @@ class Repository
public function loadOne() : ? object
{
return $this->limit(1)->selectSqlQuery()->collectionFromQuery()[0];
return $this->limit(1)->selectSqlQuery()->collectionFromQuery()[0] ?? null;
}
public function loadOneFromField($field, $value) : ? object
@@ -113,7 +113,7 @@ class Repository
throw new Exception\EntityPrimaryKeyUnknown("A primary key value has to be defined to delete an item.");
}
return (bool) $this->wherePrimaryKey($value)->deleteOne()->rowCount();
return (bool) $this->wherePrimaryKey($value)->deleteOne()->rowCount;
}
public function destroy(object $entity) : bool
@@ -160,13 +160,13 @@ class Repository
if ( $replace || ! $entity->isLoaded() ) {
# $dataset = array_filter($dataset, fn($item, $field) => ! ($this->entityResolver->searchFieldAnnotation($field, new Field, false)->readonly ?? false), \ARRAY_FILTER_USE_BOTH);
$statement = $this->insertSqlQuery($fieldsAndValue ?? $dataset, $replace)->runInsertQuery();
$pdoObject = $this->insertSqlQuery($fieldsAndValue ?? $dataset, $replace)->runInsertQuery();
if ( null !== $primaryKeyDefinition ) {
$pkField = key($primaryKeyDefinition);
if ($statement->lastInsertId ) {
$dataset[$pkField] = $statement->lastInsertId;
if ($pdoObject->lastInsertId ) {
$dataset[$pkField] = $pdoObject->lastInsertId;
}
elseif ($replace) {
$pkValue = $dataset[$pkField];
@@ -175,7 +175,7 @@ class Repository
$entity->entityFillFromDataset($dataset, true);
return (bool) ($pkValue ?? $statement->lastInsertId);
return (bool) ( $pkValue ?? $pdoObject->lastInsertId );
}
else {
if ( $primaryKeyDefinition === null ) {
@@ -193,7 +193,7 @@ class Repository
$entity->entityFillFromDataset($dataset, true);
return $update ? (bool) $update->rowCount() : false;
return $update ? (bool) $update->rowCount : false;
}
}
@@ -262,7 +262,7 @@ class Repository
$entity->entityFillFromDataset($dataset, true);
return $update ? (bool) $update->rowCount() : false;
return $update ? (bool) $update->rowCount : false;
}
}
}