Class sqlquery

Description

SQLquery class An SQL Statement Text Container.

This class is the parent of the main dbquery class which directs the query to the database. It is mainly a container of SQL query text, in the variable 'sql', but also offers a few basic methods for building queries. For complex queries however, build your own in a string and then just set the 'sql' variable.

Located in /query-defs.php (line 265)


	
			
Direct descendents
Class Description
 class dbquery DB Query class This class is the one which executes queries against the connected database.
Variable Summary
 mixed $fields
 mixed $groupby
 mixed $limit
 mixed $offset
 mixed $orderby
 mixed $sql
 mixed $tables
 mixed $type
 mixed $where
Method Summary
 sqlquery sqlquery ([string $sql = ""])
 void build ()
 void clear ()
 void fieldlist ([string $field_spec = "*"], [string $delim = ","])
 void from (string $table_spec, [string $delim = ","])
 void groupby ([string $field_spec = ""], [string $delim = ","])
 void into (string $table_spec, [string $delim = ","])
 void limit (integer $limit, integer $offset)
 void offset (integer $offset)
 void orderby ([string $field_spec = ""], [string $delim = ","])
 void rebuild ()
 void set (string $field, mixed $val)
 void tables (string $table_spec, [string $delim = ","])
 void where (string $where_clause)
Variables
mixed $fields (line 269)

List of fields in the query

mixed $groupby (line 275)

The GROUP BY clause

mixed $limit (line 279)

The LIMIT value

mixed $offset (line 281)

The OFFSET value

mixed $orderby (line 277)

The ORDER BY clause

mixed $sql = "" (line 283)

The formatted SQL query itself @see build()

mixed $tables (line 271)

List of tables in the query

mixed $type = "" (line 267)

Type of query 'SELECT', 'DELETE', 'INSERT' or 'UPDATE'

mixed $where (line 273)

The query WHERE clause components

Methods
Constructor sqlquery (line 290)

Constructor Create a new SQL Query object.

sqlquery sqlquery ([string $sql = ""])
  • string $sql: The SQL statement in full
build (line 489)

Build the SQL query This takes the various components which have been added to the object and parses them to build the full SQL statement which will be sent to the server. The result is stored in $this->sql.

NOTE: this method calls the appropriate database-specific SQL builder method.

void build ()
clear (line 298)

Clear query - Wipe all of the current query definitions.

void clear ()
fieldlist (line 344)

Define field list

Add a list of fields to return in query. This is a cumulative function which may be called more than once to add fields. You can specify the list of fields either as an array, or as a delimited list. If the latter, then default delimiter is a comma, unless you specify your own. Applicable to SELECT, DELETE and UPDATE.

void fieldlist ([string $field_spec = "*"], [string $delim = ","])
  • string $field_spec: The field list to add to the query
  • string $delim: The delimter you want to separate fields with
from (line 367)

Define table FROM list

A nicer synonym for "tables()" for SELECT

void from (string $table_spec, [string $delim = ","])
  • string $table_spec: The table list to add to the query
  • string $delim: The delimiter you want to separate tables with
groupby (line 388)

Define group by field list The fields can be an array, or a delimited list. If the latter, then default delimiter is a comma, unless you specify your own.

void groupby ([string $field_spec = ""], [string $delim = ","])
  • string $field_spec: The field list to add to the GROUP BY. Do not include words "GROUP BY".
  • string $delim: The delimiter you want to separate the fields with
into (line 377)

Define table INSERT INTO list

A nicer synonym for "tables()" for INSERT

void into (string $table_spec, [string $delim = ","])
  • string $table_spec: The table list to add to the query
  • string $delim: The delimiter you want to separate tables with
limit (line 409)

Define query LIMIT

void limit (integer $limit, integer $offset)
  • integer $limit: Numeric value for limit rows to return. Do not include the word "LIMIT".
  • integer $offset: Numeric value for start row. Do not include the word "OFFSET".
offset (line 417)

Define query OFFSET

void offset (integer $offset)
  • integer $offset: Numeric value for start row. Do not include the word "OFFSET".
orderby (line 400)

Define order field list Defines the Sort order field list. The fields can be an array, or a delimited list. If the latter, then default delimiter is a comma, unless you specify your own.

void orderby ([string $field_spec = ""], [string $delim = ","])
  • string $field_spec: The field list to add to the ORDER BY. Do not include words "ORDER BY".
  • string $delim: The delimiter you want to separate the fields with
rebuild (line 476)

This is useful when you change some part of the query after it has been executed once, and want it to rebuild the SQL anew before it gets executed again.

void rebuild ()
set (line 427)

Define field assignments Defines the field assignment clauses for UPDATE and INSERT queries.

void set (string $field, mixed $val)
  • string $field: The name of the field to assign a value to
  • mixed $val: The value to assign to the field. Processed according to type.
tables (line 357)

Define table list

Add the table specification to our list. This is a cumulative function which may be called more than once to add tables. You can specify the list of tables either as an array, or as a delimited list. If the latter, then default delimiter is a comma, unless you specify your own.

void tables (string $table_spec, [string $delim = ","])
  • string $table_spec: The table list to add to the query
  • string $delim: The delimiter you want to separate tables with
where (line 465)

Add WHERE clause component

This function allows you to add a WHERE clause component. An example might be something like: "AND c.foo='myval'". Either call this once with the whole WHERE cluase string (minus the word "WHERE"), or multiple times with parts of the where clause as in the example above.

void where (string $where_clause)
  • string $where_clause: A WHERE clause component, without the "WHERE".

Documentation generated by phpDocumentor 1.3.0RC3