diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-12-09 11:22:11 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-12-09 11:22:11 +0000 |
commit | 7c30a1bac9ce4843178203040306c7ffd4dbc20c (patch) | |
tree | a2e3f02902ca6e36229e22db12f8945ebcedeede /includes/database/sqlite | |
parent | 6f859fdd8fa5272a3491074792c0c0015051cee9 (diff) | |
download | brdo-7c30a1bac9ce4843178203040306c7ffd4dbc20c.tar.gz brdo-7c30a1bac9ce4843178203040306c7ffd4dbc20c.tar.bz2 |
- Patch #342693 by Damien Tournoud et al: DatabaseStatement Prefect iterator did not implement a proper forward-only one cursor.
Diffstat (limited to 'includes/database/sqlite')
-rw-r--r-- | includes/database/sqlite/database.inc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/includes/database/sqlite/database.inc b/includes/database/sqlite/database.inc index e10c7c1f0..e580e8c3f 100644 --- a/includes/database/sqlite/database.inc +++ b/includes/database/sqlite/database.inc @@ -246,21 +246,27 @@ class DatabaseStatement_sqlite extends DatabaseStatementPrefetch implements Iter } } if ($rename_columns) { + // DatabaseStatementPrefetch already extracted the first row, + // put it back into the result set. + if (isset($this->currentRow)) { + $this->data[0] = &$this->currentRow; + } + + // Then rename all the columns across the result set. foreach ($this->data as $k => $row) { foreach ($rename_columns as $old_column => $new_column) { $this->data[$k][$new_column] = $this->data[$k][$old_column]; unset($this->data[$k][$old_column]); } } - } - // We will iterate this array so we need to make sure the array pointer is - // at the beginning. - reset($this->data); + // Finally, extract the first row again. + $this->currentRow = $this->data[0]; + unset($this->data[0]); + } return $return; } - } /** |