atkStatement __construct(
atkDb
$db, string
$query
)
|
|
Constructs a new statement for the given query.
Parameters:
|
atkDb |
$db: |
database instance |
|
string |
$query: |
SQL query |
API Tags:
Close this statement.
Frees all resources after which this statement cannot be used anymore. If you want to re-use the statement, use the atkStatement::reset() method.
API Tags:
void execute(
[
$params = array()]
)
|
|
Executes the statement.
Parameters:
|
array |
$params: |
bind parameters |
API Tags:
Fetches the next row from the result set.
API Tags:
| Return: | next row or false if there are no more rows |
| Access: | public |
void getAffectedRowCount(
)
|
|
Returns the number of affected rows in case of an INSERT, UPDATE or DELETE query.
API Tags:
Get all rows for the given query.
NOTE: This is not an efficient way to retrieve records, as this will load all records into an array in memory. If you retrieve a lot of records, you are better of using atkStatement::getIterator which only retrieves one row at a time.
Depending on the database driver, using this method multiple times might result in the query to be executed multiple times.
API Tags:
| Return: | rows |
| Access: | public |
array getAllRowsAssoc(
[int|string
$keyColumn = 0]
)
|
|
Get rows in an associative array with the given column used as key for the rows.
NOTE: This is not an efficient way to retrieve records, as this will load all records into an array in memory. If you retrieve a lot of records, you are better of using atkStatement::getIterator which only retrieves one row at a time.
Depending on the database driver, using this method multiple times might result in the query to be executed multiple times.
Parameters:
|
int|string |
$keyColumn: |
column index / name (default first column) to be used as key |
API Tags:
| Return: | rows |
| Access: | public |
array getAllValues(
[int|string
$valueColumn = 0]
)
|
|
Get an array with all the values in the specified column.
NOTE: This is not an efficient way to retrieve records, as this will load all records into an array in memory. If you retrieve a lot of records, you are better of using atkStatement::getIterator which only retrieves one row at a time.
Depending on the database driver, using this method multiple times might result in the query to be executed multiple times.
Parameters:
|
int|string |
$valueColumn: |
column index / name (default first column) to be used as value |
API Tags:
| Return: | with values |
| Access: | public |
array getAllValuesAssoc(
[int|string
$keyColumn = 0], [int|string
$valueColumn = 1]
)
|
|
Get rows in an associative array with the given key column used as key and the given value column used as value.
NOTE: This is not an efficient way to retrieve records, as this will load all records into an array in memory. If you retrieve a lot of records, you are better of using atkStatement::getIterator which only retrieves one row at a time.
Depending on the database driver, using this method multiple times might result in the query to be executed multiple times.
Parameters:
|
int|string |
$keyColumn: |
column index / name (default first column) to be used as key |
|
int|string |
$valueColumn: |
column index / name (default first column) to be used as value |
API Tags:
| Return: | rows |
| Access: | public |
Returns the database instance.
API Tags:
| Return: | database instance |
| Access: | public |
Returns the first row.
NOTE: Depending on the database driver, using this method multiple times might result in the query to be executed multiple times.
API Tags:
| Return: | row |
| Access: | public |
mixed getFirstValue(
[int|string
$valueColumn = 0], [mixed
$fallback = null]
)
|
|
Get the value of the first (or the given) column of the first row in the result.
NOTE: Depending on the database driver, using this method multiple times might result in the query to be executed multiple times.
Parameters:
|
int|string |
$valueColumn: |
column index / name (default first column) to be used as value |
|
mixed |
$fallback: |
fallback value if no result |
API Tags:
| Return: | first value |
| Access: | public |
Returns an iterator for iterating over the result rows for this statement.
NOTE: Depending on the database driver, using this method multiple times might result in the query to be executed multiple times.
API Tags:
| Return: | iterator |
| Access: | public |
Implementation of:
- IteratorAggregate::getIterator
Returns the query on which this statement is based.
API Tags:
| Return: | query |
| Access: | public |
Resets this statement so that it can be re-used again.
API Tags:
Moves the cursor back to the beginning of the result set.
NOTE: Depending on the database driver, using this method might result in the query to be executed again.
API Tags:
Redefined in descendants as:
Frees up all resources for this statement. The statement cannot be re-used anymore.
API Tags:
| Abstract: | |
| Access: | protected |
Redefined in descendants as:
void _execute(
array
$params
)
|
|
Executes the statement using the given bind parameters.
Parameters:
|
array |
$params: |
bind parameters |
API Tags:
| Abstract: | |
| Access: | protected |
Redefined in descendants as:
Fetches the next row from the result set.
API Tags:
| Return: | next row from the result set (false if no other rows exist) |
| Abstract: | |
| Access: | protected |
Redefined in descendants as:
void _getAffectedRowCount(
)
|
|
Returns the number of affected rows in case of an INSERT, UPDATE or DELETE query. Called immediatly after atkStatement::_execute().
API Tags:
| Abstract: | |
| Access: | protected |
Redefined in descendants as:
array _getBindPositions(
)
|
|
Returns the positions for the bind parameters in the query.
The key of the array contains the character position, the value contains the bind parameter name or offset.
API Tags:
| Return: | bind positions |
| Access: | protected |
array _getLatestParams(
)
|
|
Get latest execution parameters.
API Tags:
| Return: | execution parameters |
| Access: | protected |
string _getParsedQuery(
)
|
|
Returns the parsed query for this statement (e.g. named bind parameters are replaced by anonymous bind parameters).
API Tags:
Parses the query. Named bind parameters are replaced by anonymous bind parameters and the positions of the different named/anonymous bind parameters are made available for later use.
API Tags:
Prepares the statement for execution.
API Tags:
| Abstract: | |
| Access: | protected |
Redefined in descendants as:
Resets the statement so that it can be re-used again.
API Tags:
| Abstract: | |
| Access: | protected |
Redefined in descendants as:
void _validateParams(
array
$params
)
|
|
Validates if all bind parameters are supplied.
Parameters:
|
array |
$params: |
bind parameters |
API Tags: