From df687bc492cdc94a15e66c99a1ab2c924f4bd590 Mon Sep 17 00:00:00 2001 From: Dennis <37074310+bosse-online@users.noreply.github.com> Date: Thu, 6 Oct 2022 12:13:16 +0200 Subject: [PATCH 1/4] Use ATTR_DEFAULT_FETCH_MODE on lower PHP versions. PDO::FETCH_DEFAULT constant only exists in PHP 8 or higher. So check if PDO::ATTR_DEFAULT_FETCH_MODE is defined, too. Use the current PDO instance to allow changes via the PDO options. --- src/Queries/Base.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Queries/Base.php b/src/Queries/Base.php index b05aae1..7ef2ce8 100644 --- a/src/Queries/Base.php +++ b/src/Queries/Base.php @@ -50,7 +50,14 @@ abstract class Base implements IteratorAggregate */ protected function __construct(Query $fluent, $clauses) { - $this->currentFetchMode = defined('PDO::FETCH_DEFAULT') ? PDO::FETCH_DEFAULT : PDO::FETCH_BOTH; + if (defined('PDO::FETCH_DEFAULT)')) { + $this->currentFetchMode = $fluent->getPdo()->getAttribute(PDO::FETCH_DEFAULT); + } elseif (defined('PDO::ATTR_DEFAULT_FETCH_MODE)')) { + $this->currentFetchMode = $fluent->getPdo()->getAttribute(PDO::ATTR_DEFAULT_FETCH_MODE); + } else { + $this->currentFetchMode = $fluent->getPdo()->getAttribute(PDO::FETCH_BOTH); + } + $this->fluent = $fluent; $this->clauses = $clauses; $this->result = null; From aa5d9e795419ed271751f1e6a88c8cdfc2393c71 Mon Sep 17 00:00:00 2001 From: Dennis <37074310+bosse-online@users.noreply.github.com> Date: Wed, 12 Oct 2022 19:28:52 +0200 Subject: [PATCH 2/4] Remove incorrect brackets and set default to PDO::FETCH_BOTH --- src/Queries/Base.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Queries/Base.php b/src/Queries/Base.php index 7ef2ce8..641893e 100644 --- a/src/Queries/Base.php +++ b/src/Queries/Base.php @@ -49,13 +49,13 @@ abstract class Base implements IteratorAggregate * @param $clauses */ protected function __construct(Query $fluent, $clauses) - { - if (defined('PDO::FETCH_DEFAULT)')) { + { + if (defined('PDO::FETCH_DEFAULT')) { $this->currentFetchMode = $fluent->getPdo()->getAttribute(PDO::FETCH_DEFAULT); - } elseif (defined('PDO::ATTR_DEFAULT_FETCH_MODE)')) { + } elseif (defined('PDO::ATTR_DEFAULT_FETCH_MODE')) { $this->currentFetchMode = $fluent->getPdo()->getAttribute(PDO::ATTR_DEFAULT_FETCH_MODE); } else { - $this->currentFetchMode = $fluent->getPdo()->getAttribute(PDO::FETCH_BOTH); + $this->currentFetchMode = PDO::FETCH_BOTH; } $this->fluent = $fluent; From adda4acc9dcf9f2089a7aee3f4436d4d972ee505 Mon Sep 17 00:00:00 2001 From: Dennis <37074310+bosse-online@users.noreply.github.com> Date: Wed, 12 Oct 2022 19:38:52 +0200 Subject: [PATCH 3/4] Use default values if no options set. --- src/Queries/Base.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Queries/Base.php b/src/Queries/Base.php index 641893e..a2fc04b 100644 --- a/src/Queries/Base.php +++ b/src/Queries/Base.php @@ -51,9 +51,9 @@ abstract class Base implements IteratorAggregate protected function __construct(Query $fluent, $clauses) { if (defined('PDO::FETCH_DEFAULT')) { - $this->currentFetchMode = $fluent->getPdo()->getAttribute(PDO::FETCH_DEFAULT); + $this->currentFetchMode = $fluent->getPdo()->getAttribute(PDO::FETCH_DEFAULT) ?? PDO::FETCH_DEFAULT; } elseif (defined('PDO::ATTR_DEFAULT_FETCH_MODE')) { - $this->currentFetchMode = $fluent->getPdo()->getAttribute(PDO::ATTR_DEFAULT_FETCH_MODE); + $this->currentFetchMode = $fluent->getPdo()->getAttribute(PDO::ATTR_DEFAULT_FETCH_MODE) ?? PDO::ATTR_DEFAULT_FETCH_MODE; } else { $this->currentFetchMode = PDO::FETCH_BOTH; } From 84870006a05279bd3628aa09ee334cdf51f86353 Mon Sep 17 00:00:00 2001 From: Dennis <37074310+bosse-online@users.noreply.github.com> Date: Wed, 9 Nov 2022 16:02:09 +0100 Subject: [PATCH 4/4] Update Common.php Disable smart joins by default. --- src/Queries/Common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Queries/Common.php b/src/Queries/Common.php index fefd253..1ac86ee 100644 --- a/src/Queries/Common.php +++ b/src/Queries/Common.php @@ -49,7 +49,7 @@ abstract class Common extends Base protected $joins = []; /** @var bool - Disable adding undefined joins to query? */ - protected $isSmartJoinEnabled = true; + protected $isSmartJoinEnabled = false; /** * @param string $name