aboutsummaryrefslogtreecommitdiffstats
path: root/core/namespace/ORM
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2023-09-23 23:08:02 +0200
committerThomas Lange <code@nerdmind.de>2023-09-23 23:19:38 +0200
commit09f52cfcc8ced8bed60e5c1702e6f35cf3fe1f29 (patch)
treeab426c212eb030dee4bb81099a26a4c5d7666ada /core/namespace/ORM
parent682c761c39d7368928201fe5eb4a3481eca89e35 (diff)
downloadblog-09f52cfcc8ced8bed60e5c1702e6f35cf3fe1f29.tar.gz
blog-09f52cfcc8ced8bed60e5c1702e6f35cf3fe1f29.tar.xz
blog-09f52cfcc8ced8bed60e5c1702e6f35cf3fe1f29.zip
Pass NULL instead of array containing NULL element
Diffstat (limited to 'core/namespace/ORM')
-rw-r--r--core/namespace/ORM/Repositories/CategoryRepository.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/core/namespace/ORM/Repositories/CategoryRepository.php b/core/namespace/ORM/Repositories/CategoryRepository.php
index 8692079..7c7b3f9 100644
--- a/core/namespace/ORM/Repositories/CategoryRepository.php
+++ b/core/namespace/ORM/Repositories/CategoryRepository.php
@@ -42,7 +42,13 @@ class CategoryRepository extends Repository {
$query = sprintf($query, $table, $field, $check, $table);
$Statement = $this->Database->prepare($query);
- $Statement->execute([$value]);
+ $Statement->execute(
+ # If $value is NULL, pass NULL instead of an array with one NULL
+ # element. PHP >= 8 will throw a PDOException when the number of
+ # bound variables doesn't matches the number of tokens ("?") in
+ # the SQL query, which is the case here if $value is NULL.
+ is_null($value) ? NULL : [$value]
+ );
# TODO: Virtual column _depth shall not be fetched into the entity class
return $this->fetchEntities($Statement);