Query
class Query implements IteratorAggregate
Abstract query-result class. A query result provides an iterator that returns a map for each record of a query result.
The map should be keyed by the column names, and the values should use the following types:
- boolean returned as integer 1 or 0 (to ensure consistency with MySQL that doesn't have native booleans)
- integer types returned as integers
- floating point / decimal types returned as floats
- strings returned as strings
- dates / datetimes returned as strings
Note that until SilverStripe 4.3, bugs meant that strings were used for every column type.
Once again, this should be subclassed by an actual database implementation. It will only ever be constructed by a subclass of SS_Database. The result of a database query - an iteratable object that's returned by DB::SS_Query
Primarily, the Query class takes care of the iterator plumbing, letting the subclasses focusing on providing the specific data-access methods that are required: {@link nextRecord()}, {@link numRecords()} and {@link seek()}
Methods
Return an array containing all the values from a specific column. If no column is set, then the first will be returned
Return an array containing all values in the leftmost column, where the keys are the same as the values.
Return a map from the first column to the second column.
Returns the first record in the result
Returns the first column of the first record.
Return an HTML table containing the full result-set
Return the next record in the query result.
Return the total number of items in the query result.
Details
at line 40
array
column(string $column = null)
Return an array containing all the values from a specific column. If no column is set, then the first will be returned
at line 61
array
keyedColumn()
Return an array containing all values in the leftmost column, where the keys are the same as the values.
at line 77
array
map()
Return a map from the first column to the second column.
at line 93
array
record()
Returns the first record in the result
at line 102
array
first()
deprecated
deprecated Use record() instead
at line 112
string
value()
Returns the first column of the first record.
at line 126
string
table()
Return an HTML table containing the full result-set
at line 161
abstract array
getIterator()
Return the next record in the query result.
at line 168
abstract int
numRecords()
Return the total number of items in the query result.