Result
class Result implements Traversable, Countable (View source)
A query result.
See [Fetching Results](pq/Result/: Fetching Results) for a general overview.
Constants
EMPTY_QUERY |
The query sent to the server was empty. |
COMMAND_OK |
The query did not generate a result set and completed successfully. |
TUPLES_OK |
The query successfully generated a result set. |
SINGLE_TUPLE |
The result contains a single row of the result set when using pq\Connection::$unbuffered. |
COPY_OUT |
COPY data can be received from the server. |
COPY_IN |
COPY data can be sent to the server. |
COPY_BOTH |
COPY in/out data transfer in progress. |
BAD_RESPONSE |
The server sent a bad response. |
NONFATAL_ERROR |
A nonfatal error (notice or warning) occurred. |
FATAL_ERROR |
A fatal error occurred. |
FETCH_ARRAY |
Fetch rows numerically indexed, where the index start with 0. |
FETCH_ASSOC |
Fetch rows associatively indexed by column name. |
FETCH_OBJECT |
Fetch rows as stdClass instance, where the column names are the property names. |
CONV_BOOL |
Automatically convert 'f' and 't' to FALSE and TRUE and vice versa. |
CONV_INT |
Automatically convert integral strings to either int if it fits into maximum integer size or else to float and vice versa. |
CONV_FLOAT |
Automatically convert floating point numbers. |
CONV_SCALAR |
Do all scalar conversions listed above. |
CONV_ARRAY |
Automatically convert arrays. |
CONV_DATETIME |
Automatically convert date strings to pq\DateTime and vice versa. |
CONV_JSON |
Automatically convert JSON. |
CONV_ALL |
Do all of the above. |
Properties
int read-only | $status | ||
string read-only | $statusMessage | The accompanying status message. |
|
string read-only | $errorMessage | Any error message if $status indicates an error. |
|
int read-only | $numRows | The number of rows in the result set. |
|
int read-only | $numCols | The number of fields in a single tuple of the result set. |
|
int read-only | $affectedRows | The number of rows affected by a statement. |
|
array read-only | $diag | Error details. See PQresultErrorField docs. |
|
int | $fetchType | The type of return value the fetch methods should return when no fetch type argument was given. Defaults to pq\Connection::$defaultFetchType. |
|
int | $autoConvert | What type of conversions to perform automatically. |
Methods
Bind a variable to a result column.
Count number of rows in this result set.
Describe a prepared statement.
Fetch all rows at once.
Fetch all rows of a single column.
Iteratively fetch a row into bound variables.
Iteratively fetch a single column.
Iteratively fetch a row.
Fetch the complete result set as a simple map, a multi dimensional array, each dimension indexed by a column.
Details
bool
bind(mixed $col, mixed $var)
Bind a variable to a result column.
See pq\Result::fetchBound().
int
count()
Count number of rows in this result set.
array
desc()
Describe a prepared statement.
NOTE: This will only return meaningful information for a result of pq\Statement::desc().
array
fetchAll(int $fetch_type = null)
Fetch all rows at once.
array
fetchAllCols(int $col = 0)
Fetch all rows of a single column.
array|null
fetchBound()
Iteratively fetch a row into bound variables.
See pq\Result::bind().
bool|null
fetchCol(mixed $ref, mixed $col = 0)
Iteratively fetch a single column.
array|object|null
fetchRow(int $fetch_type = null)
Iteratively fetch a row.
array|object
map(mixed $keys = 0, mixed $vals = null, int $fetch_type = null)
Fetch the complete result set as a simple map, a multi dimensional array, each dimension indexed by a column.