3 namespace Wikimedia\Rdbms
;
9 class SqliteResultWrapper
extends ResultWrapper
{
10 /** @var PDOStatement|null */
12 /** @var ArrayIterator|null */
17 * @param PDOStatement $result
19 public function __construct( PDOStatement
$result ) {
20 $this->result
= $result;
21 // SQLite doesn't allow buffered results or data seeking etc, so we'll
22 // use fetchAll. PDO has PDO::CURSOR_SCROLL but the SQLite C API doesn't
23 // support it, so the driver raises an error if it is used.
24 $this->rows
= $result->fetchAll( PDO
::FETCH_OBJ
);
27 protected function doNumRows() {
28 return count( $this->rows
);
31 protected function doFetchObject() {
32 return $this->rows
[$this->currentPos
] ??
false;
35 protected function doFetchRow() {
36 $obj = $this->doFetchObject();
37 if ( is_object( $obj ) ) {
39 $row = get_object_vars( $obj );
40 foreach ( $row as $value ) {
49 protected function doSeek( $pos ) {
50 // Nothing to do -- parent updates $this->currentPos
53 protected function doFree() {
58 protected function doGetFieldNames() {
60 return array_keys( get_object_vars( $this->rows
[0] ) );