MediaWiki REL1_40
PostgresResultWrapper.php
Go to the documentation of this file.
1<?php
2
3namespace Wikimedia\Rdbms;
4
7 private $db;
9 private $handle;
11 private $result;
12
19 public function __construct( DatabasePostgres $db, $handle, $result ) {
20 $this->db = $db;
21 $this->handle = $handle;
22 $this->result = $result;
23 }
24
25 protected function doNumRows() {
26 return pg_num_rows( $this->result );
27 }
28
29 protected function doFetchObject() {
30 // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
31 return @pg_fetch_object( $this->result );
32 }
33
34 protected function doFetchRow() {
35 // phpcs:ignore Generic.PHP.NoSilencedErrors.Discouraged
36 return @pg_fetch_array( $this->result );
37 }
38
39 protected function doSeek( $pos ) {
40 pg_result_seek( $this->result, $pos );
41 }
42
43 protected function doFree() {
44 return pg_free_result( $this->result );
45 }
46
47 protected function doGetFieldNames() {
48 $names = [];
49 $n = pg_num_fields( $this->result );
50 for ( $i = 0; $i < $n; $i++ ) {
51 $names[] = pg_field_name( $this->result, $i );
52 }
53 return $names;
54 }
55}
Postgres database abstraction layer.
__construct(DatabasePostgres $db, $handle, $result)
doFetchObject()
Get the next row as a stdClass object, or false if iteration has proceeded past the end.
doGetFieldNames()
Get the field names in the result set.
doFetchRow()
Get the next row as an array containing the data duplicated, once with string keys and once with nume...
doNumRows()
Get the number of rows in the result set.
doSeek( $pos)
Modify the current cursor position to the row with the specified offset.
Result wrapper for grabbing data queried from an IDatabase object.