class PDOQuery extends SS_Query (View source)

A result-set from a PDO database.

Properties

protected array $currentRecord

The current record in the interator.

from  SS_Query
protected int $rowNum

The number of the current row in the interator.

from  SS_Query
protected bool $queryHasBegun

Flag to keep track of whether iteration has begun, to prevent unnecessary seeks

from  SS_Query
protected PDOStatement $statement

The internal MySQL handle that points to the result set.

protected $results

Methods

public
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

from  SS_Query
public
array
keyedColumn()

Return an array containing all values in the leftmost column, where the keys are the same as the values.

from  SS_Query
public
array
map()

Return a map from the first column to the second column.

from  SS_Query
public
array
record()

Returns the next record in the iterator.

from  SS_Query
public
string
value()

Returns the first column of the first record.

from  SS_Query
public
string
table()

Return an HTML table containing the full result-set

from  SS_Query
public
array
rewind()

Iterator function implementation. Rewind the iterator to the first item and return it.

from  SS_Query
public
array
current()

Iterator function implementation. Return the current item of the iterator.

from  SS_Query
public
array
first()

Iterator function implementation. Return the first item of this iterator.

from  SS_Query
public
int
key()

Iterator function implementation. Return the row number of the current item.

from  SS_Query
public
array
next()

Iterator function implementation. Return the next record in the iterator.

from  SS_Query
public
bool
valid()

Iterator function implementation. Check if the iterator is pointing to a valid item.

from  SS_Query
public
array
nextRecord()

Return the next record in the query result.

public
int
numRecords()

Return the total number of items in the query result.

public
array
seek($row)

Go to a specific row number in the query result and return the record.

public
__construct(PDOStatement $statement)

Hook the result-set given into a Query class, suitable for use by SilverStripe.

Details

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

Parameters

string $column

Return Value

array

array keyedColumn()

Return an array containing all values in the leftmost column, where the keys are the same as the values.

Return Value

array

array map()

Return a map from the first column to the second column.

Return Value

array

array record()

Returns the next record in the iterator.

Return Value

array

string value()

Returns the first column of the first record.

Return Value

string

string table()

Return an HTML table containing the full result-set

Return Value

string

array rewind()

Iterator function implementation. Rewind the iterator to the first item and return it.

Makes use of seek()} and {@link numRecords(), takes care of the plumbing.

Return Value

array

array current()

Iterator function implementation. Return the current item of the iterator.

Return Value

array

array first()

Iterator function implementation. Return the first item of this iterator.

Return Value

array

int key()

Iterator function implementation. Return the row number of the current item.

Return Value

int

array next()

Iterator function implementation. Return the next record in the iterator.

Makes use of nextRecord(), takes care of the plumbing.

Return Value

array

bool valid()

Iterator function implementation. Check if the iterator is pointing to a valid item.

Return Value

bool

array nextRecord()

Return the next record in the query result.

Return Value

array

int numRecords()

Return the total number of items in the query result.

Return Value

int

array seek($row)

Go to a specific row number in the query result and return the record.

Parameters

$row

Return Value

array

__construct(PDOStatement $statement)

Hook the result-set given into a Query class, suitable for use by SilverStripe.

Parameters

PDOStatement $statement

The internal PDOStatement containing the results