document x.1.0 changes
[mdref/mdref-pq] / pq / Result.md
1 # class pq\Result implements Traversable, Countable
2
3 A query result.
4
5 See [Fetching Results](pq/Result/: Fetching Results) for a general overview.
6
7 ## Constants:
8
9 ### Status values:
10
11 * EMPTY_QUERY
12 The query sent to the server was empty.
13 * COMMAND_OK
14 The query did not generate a result set and completed successfully.
15 * TUPLES_OK
16 The query successfully generated a result set.
17 * SINGLE_TUPLE
18 The result contains a single row of the result set when using pq\Connection::$unbuffered.
19 * COPY_OUT
20 COPY data can be recevied from the server.
21 * COPY_IN
22 COPY data can be sent to the server.
23 * BAD_RESPONSE
24 The server sent a bad response.
25 * NONFATAL_ERROR
26 A nonfatal error (notice or warning) occurred.
27 * FATAL_ERROR
28 A fatal error occurred.
29
30
31 ### Fetch types:
32
33 * FETCH_ARRAY
34 Fetch rows numerically indexed, where the index start with 0.
35 * FETCH_ASSOC
36 Fetch rows associatively indexed by column name.
37 * FETCH_OBJECT
38 Fetch rows as stdClass instance, where the column names are the property names.
39
40 ### Conversion bits:
41
42 * CONV_BOOL
43 Automatically convert 'f' and 't' to FALSE and TRUE and vice versa.
44 * CONV_INT
45 Automatically convert integral strings to either int if it fits into maximum integer size or else to float and vice versa.
46 * CONV_FLOAT
47 Automatically convert floating point numbers.
48 * CONV_SCALAR
49 Do all scalar conversions listed above.
50 * CONV_ARRAY
51 Automatically convert arrays.
52 * CONV_DATETIME
53 Automatically convert date strings to pq\DateTime and vice versa.
54 * CONV_JSON
55 Automatically convert JSON.
56 * CONV_ALL
57 Do all of the above.
58
59
60 ## Properties:
61
62 * public (readonly) int $status
63 A [status constant](pq/Result#Status.values:).
64 * public (readonly) string $statusMessage
65 The accompanying status messsage.
66 * public (readonly) string $errorMessage
67 Any error message if $status indicates an error.
68 * public (readonly) int $numRows
69 The number of rows in the result set.
70 * public (readonly) int $numCols
71 The number of fields in a single tuple of the result set.
72 * public (readonly) int $affectedRows
73 The number of rows affected by a statement.
74 * public (readonly) array $diag
75 Error details. See [PQresultErrorField](https://www.postgresql.org/docs/current/static/libpq-exec.html#LIBPQ-PQRESULTERRORFIELD) docs.
76 * public int $fetchType = pq\Result::FETCH_ARRAY
77 The [type of return value](pq/Result#Fetch.types:) the fetch methods should return when no fetch type argument was given. Defaults to pq\Connection::$defaultFetchType.
78 * public int $autoConvert = pq\Result::CONV_ALL
79 What [type of conversions](pq/Result#Conversion.bits:) to perform automatically.