LICENSE

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

– Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

– Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

– Neither the name of Philip J. Riesch nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PHILIP J. RIESCH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

DESCRIPTION

The Query class is the primary abstraction of all possible MySQL queries that can be made on a MySQL database.

This class defines all of the constants that can be used for parameter operators, data types, order constants, and lock constants.

Member Function Documentation

Query::enableLimits

(

$limits

)

Enable limits on the query.

Parameters

$limits

boolean Whether limits should be enabled on the query.

Query::makeLimitString

(

&

$query_string,

&

$dtype_string

)

protected

Helper function that generates the limit string (SQL limit clause)

Parameters

&$query_string

string

&$dtype_string

string

Query::makeParameterString

(

$parameters,

&

$query_string,

&

$dtype_string,

$where = true

)

protected

Helper function for makeQuery that recursively generates the parameter string (SQL where clause)

Parameters control what would be the contents of the 'where' clause in a SQL statement.

Parameters can be either a single compare, multiple compares joined by boolean operators, or they can be nested statements that form complex boolean expressions.

The parameters are controled with a structured array. In general: the array will have the following format:

The first item in the array needs 3 objects: the field to compare, the operator to use, and the data type of the value that we are going to pass when we execute the query. The second item needs 4 objects. The first object is the boolean join that relates this statement to the first statement, and the second, third, and fourth object is the same as the first statement.

Consider as an example the following SQL snippet:

... where NumericalTableField >= ? ...

We are comparing whether NumericalTableField is greater than or equal to some integer. Represented as a parameter format array this query would be:

Get the picture? Notice how the second array has that first value that determines the boolean relationship that this statement has with the statement that precedes it.

Let's get complicated. Say that there is some range of numbers. And in our theoretical table we are interested in rows that fall outside of this range, i.e. they are greater than the range or less than the range, but not equal to the range. So we would need an 'or' statement to accomplish this. But we also want to match that text tag. So we need a complex query to do it.