MediaWiki REL1_37
PostgresResultWrapper.php
Go to the documentation of this file.
1<?php
2
3namespace Wikimedia\Rdbms;
4
5use 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
34 public function getInternalResult() {
35 return $this->result;
36 }
37
38 protected function doNumRows() {
39 return pg_num_rows( $this->result );
40 }
41
42 protected function doFetchObject() {
43 AtEase::suppressWarnings();
44 $row = pg_fetch_object( $this->result );
45 AtEase::restoreWarnings();
46 return $row;
47 }
48
49 protected function doFetchRow() {
50 AtEase::suppressWarnings();
51 $row = pg_fetch_array( $this->result );
52 AtEase::restoreWarnings();
53 return $row;
54 }
55
56 protected function doSeek( $pos ) {
57 pg_result_seek( $this->result, $pos );
58 }
59
60 protected function doFree() {
61 return pg_free_result( $this->result );
62 }
63
64 protected function doGetFieldNames() {
65 $names = [];
66 $n = pg_num_fields( $this->result );
67 for ( $i = 0; $i < $n; $i++ ) {
68 $names[] = pg_field_name( $this->result, $i );
69 }
70 return $names;
71 }
72}
__construct(DatabasePostgres $db, $handle, $result)
getInternalResult()
Get the underlying result object or array.
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.