From 978c3718205cf520bf106326fc9b250ea6579b11 Mon Sep 17 00:00:00 2001 From: Thomas Portelange Date: Mon, 12 Mar 2018 14:04:43 +0100 Subject: [PATCH] return 0 for non iterable results If there are no columns, it's not a iterable result set and we can return 0. This fixes issues with things like CREATE statement. --- code/SQLite3Query.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/SQLite3Query.php b/code/SQLite3Query.php index e29a88d..2d77d31 100644 --- a/code/SQLite3Query.php +++ b/code/SQLite3Query.php @@ -58,6 +58,11 @@ class SQLite3Query extends Query */ public function numRecords() { + // Some queries are not iterable using fetchArray like CREATE statement + if (!$this->handle->numColumns()) { + return 0; + } + $this->handle->reset(); $c=0; while ($this->handle->fetchArray()) {