class MysqlReader extends PdoReader (View source)

Class MysqlReader

Methods

$this
setQuery(Query $query)

setQuery

mixed
loadResult()

Method to get the first field of the first row of the result set from the database query.

mixed
loadColumn(integer $offset)

Method to get an array of values from the $offset field in each row of the result set from the database query.

mixed
loadArray()

Method to get the first row of the result set from the database query as an array. Columns are indexed numerically so the first column in the result set would be accessible via $row[0], etc.

mixed
loadArrayList(string $key = null)

Method to get an array of the result set rows from the database query where each row is an array. The array of objects can optionally be keyed by a field offset, but defaults to a sequential numeric array.

mixed
loadAssoc()

Method to get the first row of the result set from the database query as an associative array of ['field' => 'value'].

mixed
loadAssocList(string $key = null)

Method to get an array of the result set rows from the database query where each row is an associative array of ['fieldname' => 'rowvalue']. The array of rows can optionally be keyed by a field name, but defaults to a sequential numeric array.

mixed
loadObject(string $class = 'stdClass')

Method to get the first row of the result set from the database query as an object.

mixed
loadObjectList(string $key = null, string $class = 'stdClass')

Method to get an array of the result set rows from the database query where each row is an object. The array of objects can optionally be keyed by a field name, but defaults to a sequential numeric array.

mixed
count(resource $cursor = null)

count

from PdoReader
mixed
fetchArray()

Method to fetch a row from the result set cursor as an array.

from PdoReader
mixed
fetchAssoc()

Method to fetch a row from the result set cursor as an associative array.

from PdoReader
mixed
fetchObject(string $class = 'stdClass')

Method to fetch a row from the result set cursor as an object.

from PdoReader
int
countAffected(resource $cursor = null)

Get the number of affected rows for the previous executed SQL statement.

from PdoReader
string
insertId()

Method to get the auto-incremented value from the last INSERT statement.

from PdoReader
$this
freeResult()

freeResult

getDriver()

Method to get property Db

setDriver(AbstractDatabaseDriver $db)

Method to set property db

resource
getCursor()

Method to get property Cursor

from PdoReader
setCursor(resource $cursor)

Method to set property cursor

bool|mixed
fetch(int $type = \PDO::FETCH_ASSOC, int $ori = null, int $offset)

fetch

from PdoReader
array|bool
fetchAll(int $type = \PDO::FETCH_ASSOC, array $args = null, array $ctorArgs = null)

fetchAll

from PdoReader

Details

__construct(AbstractDatabaseDriver $db)

Constructor.

Parameters

AbstractDatabaseDriver $db

$this setQuery(Query $query)

setQuery

Parameters

Query $query

Return Value

$this

AbstractReader execute()

execute

Return Value

AbstractReader

DataIterator getIterator()

getIterator

Return Value

DataIterator

mixed loadResult()

Method to get the first field of the first row of the result set from the database query.

Return Value

mixed The return value or null if the query failed.

Exceptions

RuntimeException

mixed loadColumn(integer $offset)

Method to get an array of values from the $offset field in each row of the result set from the database query.

Parameters

integer $offset The row offset to use to build the result array.

Return Value

mixed The return value or null if the query failed.

Exceptions

RuntimeException

mixed loadArray()

Method to get the first row of the result set from the database query as an array. Columns are indexed numerically so the first column in the result set would be accessible via $row[0], etc.

Return Value

mixed The return value or null if the query failed.

Exceptions

RuntimeException

mixed loadArrayList(string $key = null)

Method to get an array of the result set rows from the database query where each row is an array. The array of objects can optionally be keyed by a field offset, but defaults to a sequential numeric array.

NOTE: Choosing to key the result array by a non-unique field can result in unwanted behavior and should be avoided.

Parameters

string $key The name of a field on which to key the result array.

Return Value

mixed The return value or null if the query failed.

Exceptions

RuntimeException

mixed loadAssoc()

Method to get the first row of the result set from the database query as an associative array of ['field' => 'value'].

Return Value

mixed The return value or null if the query failed.

Exceptions

RuntimeException

mixed loadAssocList(string $key = null)

Method to get an array of the result set rows from the database query where each row is an associative array of ['fieldname' => 'rowvalue']. The array of rows can optionally be keyed by a field name, but defaults to a sequential numeric array.

Parameters

string $key The name of a field on which to key the result array.

Return Value

mixed The return value or null if the query failed.

Exceptions

RuntimeException

mixed loadObject(string $class = 'stdClass')

Method to get the first row of the result set from the database query as an object.

Parameters

string $class The class name to use for the returned row object.

Return Value

mixed The return value or null if the query failed.

Exceptions

RuntimeException

mixed loadObjectList(string $key = null, string $class = 'stdClass')

Method to get an array of the result set rows from the database query where each row is an object. The array of objects can optionally be keyed by a field name, but defaults to a sequential numeric array.

NOTE: Choosing to key the result array by a non-unique field name can result in unwanted behavior and should be avoided.

Parameters

string $key The name of a field on which to key the result array.
string $class The class name to use for the returned row objects.

Return Value

mixed The return value or null if the query failed.

Exceptions

RuntimeException

in PdoReader at line line 126
mixed count(resource $cursor = null)

count

Parameters

resource $cursor

Return Value

mixed

in PdoReader at line line 35
mixed fetchArray()

Method to fetch a row from the result set cursor as an array.

Return Value

mixed Either the next row from the result set or false if there are no more rows.

in PdoReader at line line 47
mixed fetchAssoc()

Method to fetch a row from the result set cursor as an associative array.

Return Value

mixed Either the next row from the result set or false if there are no more rows.

in PdoReader at line line 61
mixed fetchObject(string $class = 'stdClass')

Method to fetch a row from the result set cursor as an object.

Parameters

string $class Unused, only necessary so method signature will be the same as parent.

Return Value

mixed Either the next row from the result set or false if there are no more rows.

in PdoReader at line line 141
int countAffected(resource $cursor = null)

Get the number of affected rows for the previous executed SQL statement.

Only applicable for DELETE, INSERT, or UPDATE statements.

Parameters

resource $cursor

Return Value

int The number of affected rows.

in PdoReader at line line 163
string insertId()

Method to get the auto-incremented value from the last INSERT statement.

Return Value

string The value of the auto-increment field from the last inserted row.

$this freeResult()

freeResult

Return Value

$this

AbstractDatabaseDriver getDriver()

Method to get property Db

Return Value

AbstractDatabaseDriver

AbstractReader setDriver(AbstractDatabaseDriver $db)

Method to set property db

Parameters

AbstractDatabaseDriver $db

Return Value

AbstractReader Return self to support chaining.

in PdoReader at line line 174
resource getCursor()

Method to get property Cursor

Return Value

resource

AbstractReader setCursor(resource $cursor)

Method to set property cursor

Parameters

resource $cursor

Return Value

AbstractReader Return self to support chaining.

in PdoReader at line line 84
bool|mixed fetch(int $type = \PDO::FETCH_ASSOC, int $ori = null, int $offset)

fetch

Parameters

int $type
int $ori
int $offset

Return Value

bool|mixed

See also

http://php.net/manual/en/pdostatement.fetch.php

in PdoReader at line line 107
array|bool fetchAll(int $type = \PDO::FETCH_ASSOC, array $args = null, array $ctorArgs = null)

fetchAll

Parameters

int $type
array $args
array $ctorArgs

Return Value

array|bool

See also

http://php.net/manual/en/pdostatement.fetchall.php