Agile Toolkit  4.2
Agile Toolkit is a powerful web development framework. Inspired by GUI Applications development
DB_dsql Class Reference
Inheritance diagram for DB_dsql:
AbstractModel AbstractObject DB_dsql_mysql DB_dsql_oracle DB_dsql_pgsql DB_dsql_prefixed DB_dsql_sqlite

Public Member Functions

 _unique (&$array, $desired=null)
 __clone ()
 __toString ()
 template ($template)
 paramBase ($param_base)
 dsql ()
 escape ($val)
 consume ($dsql, $tick=true)
 setCustom ($template, $value)
 del ($args)
 reset ()
 expr ($expr, $params=array())
 orExpr ()
 getField ($fld)
 table ($table=undefined, $alias=undefined)
 render_table ()
 render_from ()
 render_table_noalias ()
 field ($field, $table=null, $alias=null)
 render_field ()
 where ($field, $cond=undefined, $value=undefined, $kind='where')
 having ($field, $cond=undefined, $value=undefined)
 _render_where ($kind)
 render_where ()
 render_orwhere ()
 render_having ()
 join ($foreign_table, $master_field=null, $join_kind=null, $_foreign_alias=null)
 render_join ()
 group ($option)
 render_group ()
 order ($order, $desc=null)
 render_order ()
 option ($option)
 render_options ()
 option_insert ($option)
 render_options_insert ()
 args ($args)
 render_args ()
 ignore ()
 hasOption ($option)
 hasInsertOption ($option)
 limit ($cnt, $shift=0)
 render_limit ()
 set ($field, $value=undefined)
 render_set ()
 render_set_fields ()
 render_set_values ()
 bt ($s)
 _setArray ($values, $name, $parse_commas=true)
 SQLTemplate ($mode)
 call ($fx, $args=null)
 fx ($fx, $args=null)
 render_fx ()
 sum ($arg=null)
 count ($arg=null)
 execute ()
 select ()
 insert ()
 insertAll ($array)
 update ()
 replace ()
 delete ()
 truncate ()
 do_select ()
 do_insert ()
 do_update ()
 do_replace ()
 get ()
 getOne ()
 getRow ()
 getHash ()
 fetch ($mode=PDO::FETCH_ASSOC)
 fetchAll ()
 do_getOne ()
 do_getAllHash ()
 do_getAll ()
 getAll ()
 do_getRow ()
 do_getHash ()
 calc_found_rows ()
 foundRows ()
 rewind ()
 next ()
 current ()
 key ()
 valid ()
 debug ()
 render ()
 _render ()

Data Fields

 $args = array()
 $params = array()
 $extra_params = array()
 $stmt = null
 $template = null
 $mode = null
 $main_table = null
 $default_field = '*'
 $default_exception = 'Exception_DB'
 $debug = false
 $param_base = 'a'
 $bt = '`'
 $data = false
 $_iterating = false

Detailed Description

Member Function Documentation

__clone ( )

Reimplemented from AbstractObject.

Reimplemented from AbstractObject.

_render ( )
_render_where ( kind)
_setArray ( values,
parse_commas = true 
_unique ( &$  array,
desired = null 

This funcion given the associative $array and desired new key will return the best matching key which is not yet in the arary. For example if you have array('foo'=>x,'bar'=>x) and $desired is 'foo' function will return 'foo_2'. If 'foo_2' key also exists in that array, then 'foo_3' is returned and so on.

Reimplemented from AbstractObject.

args ( args)

set arguments for call()

bt ( s)

Sets flag to hint SQL (if supported) to prepare total number of columns. Use foundRows() to read this afterwards

Reimplemented in DB_dsql_mysql.

call ( fx,
args = null 

Switches to call mode. Use with args()

consume ( dsql,
tick = true 

Recursively renders sub-query or expression, combining parameters

count ( arg = null)
current ( )
debug ( )

Will set a flag which will output query (echo) as it is being rendered.

del ( args)

Removes definition for argument. $q->del('where')

delete ( )

Executes delete query

do_getAll ( )

. Use get()

. Use getHash()

do_getOne ( )

. Use getQne()

do_getRow ( )

. Use getRow()

do_insert ( )

, use insert()

, use replace()

do_select ( )

, use select()

do_update ( )

, use update()

dsql ( )

Create new dsql object which can then be used as sub-query.

escape ( val)

Converts value into parameter and returns reference. Use only during query rendering.

execute ( )

Executes any query query

expr ( expr,
params = array() 

Returns new dynamic query and initializes it to use specific template.

fetch ( mode = PDO::FETCH_ASSOC)

Will execute the query (if it's not executed already) and return first row

fetchAll ( )

. Use get()

foundRows ( )

After fetching data, call this to find out how many rows there were in total. Call calc_found_rows() for better performance

fx ( fx,
args = null 
get ( )

Will execute DSQL query and return all results inside array of hashes

getAll ( )

. Use get()

getField ( fld)

Return expression containing a properly escaped field. Use make subquery condition reference parent query

getHash ( )

Will execute DSQL query and return first row as hash (column=>value)

getOne ( )

Will execute DSQL query and return first column of a first row

getRow ( )

Will execute DSQL query and return first row as array (not hash)

group ( option)
hasInsertOption ( option)
hasOption ( option)

Check if option was defined

having ( field,
cond = undefined,
value = undefined 
ignore ( )
insert ( )

Executes insert query. Returns ID of new record.

insertAll ( array)

Inserts multiple rows of data. Uses ignore option.

key ( )
limit ( cnt,
shift = 0 

Limit row result

Reimplemented in DB_dsql_oracle.

next ( )
option ( option)

Defines query option

option_insert ( option)
order ( order,
desc = null 
orExpr ( )

Shortcut to produce expression which concatinates "where" clauses with "OR" operator

paramBase ( param_base)

Change prefix for parametric values. Useful if you are combining multiple queries.

render ( )

Converts query into string format. This will contain parametric references

Conditionally returns "from", only if table is specified

render_fx ( )

Reimplemented in DB_dsql_pgsql, and DB_dsql_oracle.

Returns template component [table]

Returns template component [table_noalias]

replace ( )

Executes replace query

reset ( )

Removes all definitions. Start from scratch

rewind ( )
select ( )

Executes select query.

set ( field,
value = undefined 
setCustom ( template,

Defines a custom template variable.

SQLTemplate ( mode)

Switches to select mode (which is default) for this query

Reimplemented in DB_dsql_pgsql.

sum ( arg = null)
template ( template)

Explicitly sets template to your query. Remember to change $this->mode if you switch this

truncate ( )

Executes truncate

update ( )

Executes update query

valid ( )

Field Documentation

$_iterating = false
$args = array()

Data accumulated by calling Definition methods, which is then used when rendering

$bt = '`'

Backticks will be added around all fields. Set this to '' if you prefer cleaner queries

Reimplemented in DB_dsql_pgsql.

$data = false
$debug = false

call $q->debug() to turn on debugging.

$default_exception = 'Exception_DB'

Exception class to use when $this->exception() is called

Reimplemented from AbstractObject.

$default_field = '*'

If no fields are defined, this field is used

$extra_params = array()

Manually-specified params

$main_table = null

Used to determine main table.

$mode = null

You can switch mode with select(), insert(), update() commands. Mode is initialized to "select" by default

$param_base = 'a'

prefix for all parameteric variables: a, a_2, a_3, etc

$params = array()

List of PDO parametical arguments for a query. Used only during rendering.

Initial value:
        'select'=>"select [options] [field] [from] [table] [join] [where] [group] [having] [order] [limit]",
        'insert'=>"insert [options_insert] into [table_noalias] ([set_fields]) values ([set_values])",
        'replace'=>"replace [options_replace] into [table_noalias] ([set_fields]) values ([set_value])",
        'update'=>"update [table_noalias] set [set] [where]",
        'delete'=>"delete from  [table_noalias] [where]",
        'truncate'=>'truncate table [table_noalias]'
$stmt = null

PDO Statement, if query is prepared. Used by iterator

$template = null

Expression to use when converting to string

The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables Enumerations