mirror of
https://github.com/silverstripe/silverstripe-sqlite3
synced 2024-10-22 17:05:37 +02:00
ENHANCEMENT Use simpler query syntax for SS3
This commit is contained in:
parent
e9edf8b381
commit
ecda380925
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user