From 0bb7119ea58267c46cd3419b152736759a9a8db3 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 27 Dec 2024 09:34:04 +0700 Subject: [PATCH] refactor: avoid repetitive call pg_last_error() --- system/Database/Postgre/Connection.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/Database/Postgre/Connection.php b/system/Database/Postgre/Connection.php index 8d2edc94296c..70f3ff461689 100644 --- a/system/Database/Postgre/Connection.php +++ b/system/Database/Postgre/Connection.php @@ -461,9 +461,10 @@ protected function _enableForeignKeyChecks() */ public function error(): array { + $lastError = pg_last_error($this->connID); return [ 'code' => '', - 'message' => ! in_array(pg_last_error($this->connID), ['', '0'], true) ? pg_last_error($this->connID) : '', + 'message' => ! in_array($lastError, ['', '0'], true) ? $lastError : '', ]; }