diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php index 718821b2a50d..46ba04304aed 100644 --- a/system/Database/MySQLi/Connection.php +++ b/system/Database/MySQLi/Connection.php @@ -346,7 +346,7 @@ protected function _escapeString(string $str): string return $str; } - if (is_null($this->connID)) + if (! $this->connID) { $this->initialize(); } diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php index b51ae095af1b..b738fb8bddc4 100644 --- a/system/Database/Postgre/Connection.php +++ b/system/Database/Postgre/Connection.php @@ -212,6 +212,11 @@ public function affectedRows(): int */ public function escape($str) { + if (! $this->connID) + { + $this->initialize(); + } + if (is_string($str) OR ( is_object($str) && method_exists($str, '__toString'))) { return pg_escape_literal($this->connID, $str); @@ -234,7 +239,7 @@ public function escape($str) */ protected function _escapeString(string $str): string { - if (is_null($this->connID)) + if (! $this->connID) { $this->initialize(); }