MediaWiki  master
PostgresResultWrapper.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Wikimedia\Rdbms;
4 
5 use Wikimedia\AtEase\AtEase;
6 
9  private $db;
11  private $handle;
13  private $result;
14 
22  $this->db = $db;
23  $this->handle = $handle;
24  $this->result = $result;
25  }
26 
27  protected function doNumRows() {
28  return pg_num_rows( $this->result );
29  }
30 
31  protected function doFetchObject() {
32  AtEase::suppressWarnings();
33  $row = pg_fetch_object( $this->result );
34  AtEase::restoreWarnings();
35  return $row;
36  }
37 
38  protected function doFetchRow() {
39  AtEase::suppressWarnings();
40  $row = pg_fetch_array( $this->result );
41  AtEase::restoreWarnings();
42  return $row;
43  }
44 
45  protected function doSeek( $pos ) {
46  pg_result_seek( $this->result, $pos );
47  }
48 
49  protected function doFree() {
50  return pg_free_result( $this->result );
51  }
52 
53  protected function doGetFieldNames() {
54  $names = [];
55  $n = pg_num_fields( $this->result );
56  for ( $i = 0; $i < $n; $i++ ) {
57  $names[] = pg_field_name( $this->result, $i );
58  }
59  return $names;
60  }
61 }
__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.