CmsDbQueryBase
in package
An abstract class for building queries and managing results.
This class is capable of managing a resultset, and encapsulates conversionof database rows into application objects.
Tags
Table of Contents
Properties
- $EOF : bool
- $fields : array<string|int, mixed>
- $limit : int
- $numpages : int
- $offset : int
- $totalrows : int
- $_args : mixed
- This member stores the original arguments passed to the constructor and used when generating the query.
- $_limit : mixed
- The (integer) page limit.
- $_offset : mixed
- The current (integer) offset in the list of results
- $_rs : mixed
- This member stores the raw database resultset object.
- $_totalmatchingrows : mixed
- The total number of rows matching the query.
Methods
- __construct() : mixed
- Constructor
- Close() : mixed
- Close the resultset and free any resources it may have claimed.
- EOF() : bool
- Test if the resultset is pointing past the last record in the returned set
- execute() : mixed
- Execute the query.
- GetMatches() : array<string|int, mixed>|null
- Return an array of matched objects.
- GetObject() : mixed
- Get the object for the current matching database row.
- MoveFirst() : mixed
- Modify the resultset object and point to the first record of the matched rows.
- MoveLast() : mixed
- Modify the resultset object and point to the last record of the matched rows.
- MoveNext() : mixed
- Modify the resultset object and point to the next record of the matched rows.
- RecordCount() : int
- Return the number of records that match the the current query subject to page limits, this method will return either the pagelimit or a lesser value.
- Rewind() : mixed
- Modify the resultset object and point to the first record of the matched rows.
- TotalMatches() : int
- Return the total number of matching records that match the current query
Properties
$EOF read-only
public
bool
$EOF
Indicates wether the resultset is past the last element (read only)
$fields read-only
public
array<string|int, mixed>
$fields
Associative array of the current row of the resultset (read only)
$limit read-only
public
int
$limit
The maximum number of rows to return in one resultset (read only)
$numpages read-only
public
int
$numpages
The total number of pages of rows that match the query (read only)
$offset read-only
public
int
$offset
The start offset of rows to return when executing the query (read only)
$totalrows read-only
public
int
$totalrows
The total number of rows in the database that match the query (read only)
$_args
This member stores the original arguments passed to the constructor and used when generating the query.
protected
mixed
$_args
= array()
$_limit
The (integer) page limit.
protected
mixed
$_limit
= 1000
$_offset
The current (integer) offset in the list of results
protected
mixed
$_offset
= 0
$_rs
This member stores the raw database resultset object.
protected
mixed
$_rs
= \null
$_totalmatchingrows
The total number of rows matching the query.
protected
mixed
$_totalmatchingrows
= \null
This value is populated after execute() is called.
Tags
Methods
__construct()
Constructor
public
__construct([mixed $args = '' ]) : mixed
Parameters
- $args : mixed = ''
-
Accepts an associative array (key=>value) with arguments for the query, or a comma separarated string of arguments.
Close()
Close the resultset and free any resources it may have claimed.
public
Close() : mixed
EOF()
Test if the resultset is pointing past the last record in the returned set
public
EOF() : bool
Return values
boolexecute()
Execute the query.
public
abstract execute() : mixed
This method should read the parameters, build and execute the database query and populate the $_totalmatchingrows and $_rs members.
This method should be smart enough to not execute the database query more than once independent of how many times it is called.
GetMatches()
Return an array of matched objects.
public
GetMatches() : array<string|int, mixed>|null
This method will iterate through all of the rows of the resultset, and convert each resulting row into an object.
The output of this method depends on the derived class.
Tags
Return values
array<string|int, mixed>|nullGetObject()
Get the object for the current matching database row.
public
abstract & GetObject() : mixed
Tags
MoveFirst()
Modify the resultset object and point to the first record of the matched rows.
public
MoveFirst() : mixed
If execute has not been called yet, this method will call it.
MoveLast()
Modify the resultset object and point to the last record of the matched rows.
public
MoveLast() : mixed
If execute has not been called yet, this method will call it.
MoveNext()
Modify the resultset object and point to the next record of the matched rows.
public
MoveNext() : mixed
If execute has not been called yet, this method will call it.
RecordCount()
Return the number of records that match the the current query subject to page limits, this method will return either the pagelimit or a lesser value.
public
RecordCount() : int
If execute has not already been called, this method will call it.
Return values
intRewind()
Modify the resultset object and point to the first record of the matched rows.
public
Rewind() : mixed
This is a synonym for MoveFirst()
If execute has not been called yet, this method will call it.
Tags
TotalMatches()
Return the total number of matching records that match the current query
public
TotalMatches() : int
If execute has not already been called, this method will call it.