CmsDbQueryBase View code

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.

since 2.0
package

CMS

license

GPL

author

Robert Campbell calguy1000@gmail.com

property-read

Associative array of the current row of the resultset (read only)

property-read

Indicates wether the resultset is past the last element (read only)

property-read

The maximum number of rows to return in one resultset (read only)

property-read

The start offset of rows to return when executing the query (read only)

property-read

The total number of rows in the database that match the query (read only)

property-read

The total number of pages of rows that match the query (read only)

Methods

__construct(mixed $args = '') 

Constructor

Arguments

mixed $args

Accepts an associative array (key=>value) with arguments for the query, or a comma separarated string of arguments.

execute() 

Execute the query.

abstract

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.

TotalMatches() : integer

Return the total number of matching records that match the current query

If execute has not already been called, this method will call it.

Response

integer

RecordCount() : integer

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.

If execute has not already been called, this method will call it.

Response

integer

MoveNext() 

Modify the resultset object and point to the next record of the matched rows.

If execute has not been called yet, this method will call it.

MoveFirst() 

Modify the resultset object and point to the first record of the matched rows.

If execute has not been called yet, this method will call it.

Rewind() 

Modify the resultset object and point to the first record of the matched rows.

This is a synonym for MoveFirst()

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.

If execute has not been called yet, this method will call it.

EOF() : boolean

Test if the resultset is pointing past the last record in the returned set

Response

boolean

Close() 

Close the resultset and free any resources it may have claimed.

GetObject() : mixed

Get the object for the current matching database row.

abstract

Response

mixed

GetMatches() : array|null

Return an array of matched objects.

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.

Response

array|null

Properties

The total number of rows matching the query.

_totalmatchingrows : 

This value is populated after execute() is called.

Type(s)

The current (integer) offset in the list of results

_offset : 

Type(s)

The (integer) page limit.

_limit : 

Type(s)

This member stores the raw database resultset object.

_rs : 

Type(s)

This member stores the original arguments passed to the constructor and used when generating the query.

_args : 

Type(s)

fields

fields : array

Associative array of the current row of the resultset (read only)

Type(s)

array

EOF

EOF : boolean

Indicates wether the resultset is past the last element (read only)

Type(s)

boolean

limit

limit : integer

The maximum number of rows to return in one resultset (read only)

Type(s)

integer

offset

offset : integer

The start offset of rows to return when executing the query (read only)

Type(s)

integer

totalrows

totalrows : integer

The total number of rows in the database that match the query (read only)

Type(s)

integer

numpages

numpages : integer

The total number of pages of rows that match the query (read only)

Type(s)

integer