From 93cb7e0cab7972030d83691cb067757ed9122906 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Tue, 22 Apr 2025 11:03:45 +0900 Subject: [PATCH] DB IO Adjustments for cursor set check and table exists check --- www/lib/CoreLibs/DB/Extended/ArrayIO.php | 10 +++++----- www/lib/CoreLibs/DB/IO.php | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/www/lib/CoreLibs/DB/Extended/ArrayIO.php b/www/lib/CoreLibs/DB/Extended/ArrayIO.php index ac98091c..50256c6a 100644 --- a/www/lib/CoreLibs/DB/Extended/ArrayIO.php +++ b/www/lib/CoreLibs/DB/Extended/ArrayIO.php @@ -39,9 +39,9 @@ class ArrayIO extends \CoreLibs\DB\IO { // main calss variables /** @var array */ - private array $table_array; // the array from the table to work on + private array $table_array = []; // the array from the table to work on /** @var string */ - private string $table_name; // the table_name + private string $table_name = ''; // the table_name /** @var string */ private string $pk_name = ''; // the primary key from this table /** @var int|string|null */ @@ -127,9 +127,9 @@ class ArrayIO extends \CoreLibs\DB\IO public function getTableArray(bool $reset = false): array { if (!$reset) { - return $this->table_array ?? []; + return $this->table_array; } - $table_array = $this->table_array ?? []; + $table_array = $this->table_array; reset($table_array); return $table_array; } @@ -194,7 +194,7 @@ class ArrayIO extends \CoreLibs\DB\IO */ public function getTableName(): string { - return $this->table_name ?? ''; + return $this->table_name; } /** diff --git a/www/lib/CoreLibs/DB/IO.php b/www/lib/CoreLibs/DB/IO.php index 232c3038..732d7a27 100644 --- a/www/lib/CoreLibs/DB/IO.php +++ b/www/lib/CoreLibs/DB/IO.php @@ -2544,7 +2544,10 @@ class IO } // only go if NO cursor exists // if cursor exists ... - if ($this->cursor_ext[$query_hash]['cursor']) { + if ( + $this->cursor_ext[$query_hash]['cursor'] instanceof \PgSql\Result || + $this->cursor_ext[$query_hash]['cursor'] == 1 + ) { if ($first_call === true) { $this->cursor_ext[$query_hash]['log'][] = 'First call'; // count the rows returned (if select)