>> YANA 4 PHP Framework >> Docs For Class DbQuery

Class DbQuery

Description

Database query builder

This class is a query builder that can be used to build SQL statements.

Note: this class does NOT untaint input data for you. It also does NOT automatically resolve foreign keys.

This class is still experimental. Names and functions might get added, removed or changed without further notice. Use at your own risk!

  • todo: check integration with DbStream - class
  • since: 2.9 RC1
  • access: public

Located in /includes/class_dbquery.php

Object
   |
   --DbQuery
Method Summary

Methods

create a new instance
DbQuery DbQuery (
object $database
)
List of parameters:
Name Type Description
$database object
Description:

This creates and initializes a new instance of this class.

get the currently selected column
string getColumn ()
Description:

Returns the lower-cased name of the currently selected column.

If none has been selected, '*' is returned.

  • access: public
get a list of the tables, the query has joined together
bool(false)|array getJoin (
[string $table = null]
)
List of parameters:
Name Type Description
$table string
Description:

If $table is not provided, all tables are returned.

  • access: public
get the list of columns the resultset is ordered by
bool(false)|array getOrderBy ()
Description:

Returns the lower-cased column name, or bool(false) if none has been set yet.

  • access: public
get the currently selected row
bool(false)|string getRow ()
Description:

Returns the lower-cased name of the currently selected column, or bool(false) if none has been selected yet.

  • access: public
get the currently selected table
bool(false)|string getTable ()
Description:

Returns the lower-cased name of the currently selected table, or bool(false) if none has been selected yet.

  • access: public
get the currently selected type of statement
int getType ()
Description:

Returns currently selected constant.

  • access: public
get the list of values
mixed &getValues ()
Description:

If none are available, NULL (not bool(false)!) is returned.

  • access: public
get the currently set where clause
array getWhere ()
Description:

Returns the current where clause.

  • access: public
check if resultset is sorted in descending order
bool isDescending ()
Description:

Returns bool(true) if sorted descending and bool(false) otherwise.

  • access: public
set source column
bool setColumn (
string $column
)
List of parameters:
Name Type Description
$column string
Description:

Returns bool(true) on success and bool(false) on error.

  • access: public
join the resultsets for two tables
bool setJoin (
[string $table = null], [string $key1 = null], [string $key2 = null]
)
List of parameters:
Name Type Description
$table string name of another table to join table1 with (when omitted will remove all previously set joins from table1)
$key1 string name of the foreign key in current table (when omitted the API will look up the key in the structure file)
$key2 string name of the key in foreign table that is referenced (may be omitted if it is the primary key)
Description:

This will join the currently selected table with another.

  • access: public
resolve key address to determine table, column and row
bool setKey (
string $key
)
List of parameters:
Name Type Description
$key string
Description:

Returns bool(true) on success and bool(false) on error.

  • access: public
set column to sort the resultset by
bool setOrderBy (
string|array $orderBy, [bool $desc = false]
)
List of parameters:
Name Type Description
$orderBy string|array column name / list of column names
$desc bool sort descending (true=yes, false=no)
Description:

Returns bool(true) on success and bool(false) on error.

  • access: public
set source row
bool setRow (
scalar $row
)
List of parameters:
Name Type Description
$row scalar
Description:

Returns bool(true) on success and bool(false) on error.

Note: does not check if row exists.

Currently you may only request 1 row or all. To search for all rows, use the wildcard '*'.

  • access: public
set source table
bool setTable (
string $table
)
List of parameters:
Name Type Description
$table string
Description:

Returns bool(true) on success and bool(false) on error.

  • access: public
select the kind of statement
bool setType (
int $type
)
List of parameters:
Name Type Description
$type int
Description:

Returns bool(true) on success and bool(false) on error.

  • access: public
set value(s) for current query
bool setValues (
 &$values
)
List of parameters:
Name Type Description
&$values
Description:

Returns bool(true) on success and bool(false) on error.

  • access: public
set where clause (filter)
bool setWhere (
[string|array $where = null]
)
List of parameters:
Name Type Description
$where string|array
Description:

The syntax is as follows: column1=value1,column2=value2,...,columnN=valueN

The alternative is as follows: array(array(0=>column1,1=>value1,2=>operator1),...) Where "operator" can be one of the following: '=', 'LIKE', '<', '>', '!=', '<=', '>='

To unset the where clause, call this function without providing a parameter.

Returns bool(true) on success and bool(false) on error.

  • access: public
build a SQL-query
string toString ()
Description:
  • access: public

Redefinition of: Object::toString()

inherited from base classes

Inherited From Object

Documentation generated on Sun, 11 Mar 2007 15:02:26 +0100 by phpDocumentor 1.3.1

yana author: Thomas MeyerHomepage: www.yanaframework.net