From ecda38092544f3b32dc3fde7e2fa82007a3cc8e6 Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Fri, 4 May 2012 10:02:00 +1200 Subject: [PATCH] ENHANCEMENT Use simpler query syntax for SS3 --- code/SQLite3Database.php | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/code/SQLite3Database.php b/code/SQLite3Database.php index 7ac9844..b7631cd 100644 --- a/code/SQLite3Database.php +++ b/code/SQLite3Database.php @@ -1187,25 +1187,14 @@ class SQLite3Query extends SS_Query { */ public function numRecords() { $c=0; - while(@$this->handle->fetchArray()) $c++; + while($this->handle->fetchArray()) $c++; $this->handle->reset(); return $c; } public function nextRecord() { - // Coalesce rather than replace common fields. - if($data = @$this->handle->fetchArray(SQLITE3_NUM)) { - foreach($data as $columnIdx => $value) { - if(preg_match('/^"([a-z0-9_]+)"\."([a-z0-9_]+)"$/i', $this->handle->columnName($columnIdx), $matches)) $columnName = $matches[2]; - else if(preg_match('/^"([a-z0-9_]+)"$/i', $this->handle->columnName($columnIdx), $matches)) $columnName = $matches[1]; - else $columnName = trim($this->handle->columnName($columnIdx),"\"' \t"); - // $value || !$ouput[$columnName] means that the *last* occurring value is shown - // !$ouput[$columnName] means that the *first* occurring value is shown - if(isset($value) || !isset($output[$columnName])) { - $output[$columnName] = is_null($value) ? null : (string)$value; - } - } - return $output; + if($data = $this->handle->fetchArray(SQLITE3_ASSOC)) { + return $data; } else { return false; }