ENHANCEMENT Use simpler query syntax for SS3

This commit is contained in:
Sean Harvey 2012-05-04 10:02:00 +12:00
parent e9edf8b381
commit ecda380925

View File

@ -1187,25 +1187,14 @@ class SQLite3Query extends SS_Query {
*/ */
public function numRecords() { public function numRecords() {
$c=0; $c=0;
while(@$this->handle->fetchArray()) $c++; while($this->handle->fetchArray()) $c++;
$this->handle->reset(); $this->handle->reset();
return $c; return $c;
} }
public function nextRecord() { public function nextRecord() {
// Coalesce rather than replace common fields. if($data = $this->handle->fetchArray(SQLITE3_ASSOC)) {
if($data = @$this->handle->fetchArray(SQLITE3_NUM)) { return $data;
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;
} else { } else {
return false; return false;
} }