PHP 클래스 DB_dsql, atk4

상속: extends AbstractModel, implements Iterator
파일 보기 프로젝트 열기: atk4/atk4 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$_iterating
$args array Data accumulated by calling Definition methods, which is then used when rendering.
$bt string Backtics are added around all fields. Set this to blank string to avoid.
$data {{{ Iterator support
$debug boolean Call $q->debug() to turn on debugging or $q->debug(false) to turn ir off.
$default_exception string Class name of default exception
$default_field string | DB_dsql If no fields are defined, this field is used.
$extra_params array Manually-specified params
$id_field string Required for non-id based tables.
$main_table boolean | string Used to determine main table.
$mode string Mode is initialized to "select" by default.
$output_mode string When you convert this object to string, the following happens:
$owner Owner of this object
$param_base string 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.
$preexec
$sql_templates Templates are used to construct most common queries. Templates may be changed in vendor-specific implementation of dsql (extending this class).
$stmt PDOStatement PDO statement if query is prepared. Used by iterator.
$template string Expression to use when converting to string

공개 메소드들

메소드 설명
SQLTemplate ( string $mode ) Switch template for this query. Determines what would be done on execute.
__clone ( )
__toString ( ) : string Convert object to string - generate SQL expression
_render ( ) : string Helper for render(), which does the actual work.
_render_where ( string $kind ) : array Subroutine which renders either [where] or [having].
_setArray ( mixed $values, string $name, boolean $parse_commas = true ) Internal method which can be used by simple param-giving methods such as option(), group(), etc.
_unique ( &$array, $desired = null ) {{{ Generic routines
andExpr ( ) : DB_dsql Shortcut to produce expression for series of conditions concatinated with "and". Useful to be passed inside where() or join().
args ( array $args ) set arguments for call(). Used by fx() and call() but you can use This with ->expr("in ([args])")->args($values);.
bt ( mixed $s ) : string Adds backtics around argument. This will allow you to use reserved SQL words as table or field names such as "table".
calcFoundRows ( ) Sets flag to hint SQL (if supported) to prepare total number of columns.
calc_found_rows ( )
call ( string $fx, array $args = null ) Sets a template for a user-defined method call with specified arguments.
concat ( ) : DB_dsql Return expression for concatinating multiple values Accepts variable number of arguments, all of them would be escaped.
consume ( string | Field | DB_dsql $dsql, boolean $tick = true ) : string Recursively renders sub-query or expression, combining parameters.
count ( string | object $arg = null ) : DB_dsql Creates expression for COUNT().
current ( )
debug ( boolean | string $msg = true ) This is identical to AbstractObject::debug(), but as an object will refer to the $owner. This is to avoid string-casting and messing up with the DSQL string.
del ( string $args ) Removes definition for argument. $q->del('where'), $q->del('fields') etc.
delete ( ) Executes delete query.
describe ( string $table = null ) : DB_dsql Creates a query for listing tables in databse-specific form Agile Toolkit DSQL does not pretend to know anything about model structure, so result parsing is up to you.
do_getAll ( )
do_getAllHash ( )
do_getHash ( )
do_getOne ( )
do_getRow ( )
do_insert ( )
do_replace ( )
do_select ( )
do_update ( )
dsql ( ) : DB_dsql Create new dsql object linked with the same database connection and bearing same data-type. You can use this method to create sub-queries.
escape ( string $val ) : string Converts value into parameter and returns reference. Use only during query rendering. Consider using consume() instead.
execute ( ) Executes current query.
expr ( string $expr, array $tags = [] ) : DB_dsql Returns new dynamic query and initializes it to use specific template.
fetch ( integer $mode = PDO::FETCH_ASSOC ) : mixed Will execute the query (if it's not executed already) and return first row.
fetchAll ( )
field ( string | array $field, string $table = null, string $alias = null ) Adds new column to resulting select by querying $field.
fieldQuery ( string | array $field, string $table = null, string $alias = null ) : DB_dsql Removes all field definitions and returns only field you specify as parameter to this method. Original query is not affected ($this) Same as for field() syntax.
foundRows ( ) : integer After fetching data, call this to find out how many rows there were in total. Call calcFoundRows() for better performance.
fx ( string $fx, array $args = null ) Executes a standard function with arguments, such as IF.
get ( ) : array Will execute DSQL query and return all results inside array of hashes.
getAll ( )
getDebugQuery ( string $r = null ) : string Return formatted debug output.
getField ( string $fld ) : DB_dsql Return expression containing a properly escaped field. Use make subquery condition reference parent query.
getHash ( ) : array Will execute DSQL query and return first row as hash (column=>value).
getOne ( ) : string Will execute DSQL query and return first column of a first row.
getRow ( ) : array Will execute DSQL query and return first row as array (not hash). If you call several times will return subsequent rows.
group ( string | object $group ) Implemens GROUP BY functionality. Simply pass either string field or expression.
hasInsertOption ( string $option ) : boolean Check if specified insert option was previously added.
hasOption ( string $option ) : boolean Check if specified option was previously added.
having ( mixed $field, string $cond = UNDEFINED, string $value = UNDEFINED ) Same syntax as where().
ignore ( ) Sets IGNORE option.
insert ( ) : integer Executes insert query. Returns ID of new record.
insertAll ( array $array ) : array Inserts multiple rows of data. Uses ignore option AVOID using this, might not be implemented correctly.
join ( string $foreign_table, mixed $master_field = null, string $join_kind = null, string $_foreign_alias = null ) Joins your query with another table.
key ( )
limit ( integer $cnt, integer $shift ) Limit how many rows will be returned.
next ( )
option ( string | expresion $option ) Defines query option, such as DISTINCT.
option_insert ( string | expresion $option ) Defines insert query option, such as IGNORE.
option_replace ( string | expresion $option ) Defines replace query option, such as IGNORE.
orExpr ( ) : DB_dsql Shortcut to produce expression which concatinates "where" clauses with "OR" operator.
order ( mixed $order, string | boolean $desc = null ) Orders results by field or Expression. See documentation for full list of possible arguments.
paramBase ( string $param_base ) Change prefix for parametric values. Not really useful.
preexec ( ) Execute query faster, but don't fetch data until iterating started. This can be done if you need to know foundRows() before fetching data.
random ( ) : DB_dsql Returns method for generating random numbers. This is used for ordering table in random order.
render ( ) : string Converts query into string format. This will contain parametric references.
render_andwhere ( ) : string Renders [andwhere].
render_args ( ) : string Renders [args].
render_field ( ) : string Returns template component [field].
render_from ( ) : string Conditionally returns "from", only if table is Specified Do not call directly.
render_fx ( ) : string Renders [fx].
render_group ( ) : string Renders [group].
render_having ( ) : string Renders [having].
render_join ( ) : string Renders [join].
render_limit ( ) : string Renders [limit].
render_options ( ) : string Renders [options].
render_options_insert ( ) : string Renders [options_insert].
render_options_replace ( ) : string Renders [options_replace].
render_order ( ) : string Renders [order].
render_orwhere ( ) : string Renders [orwhere].
render_set ( ) : string Renders [set] for UPDATE query.
render_set_fields ( ) : string Renders [set_fields] for INSERT.
render_set_values ( ) : string Renders [set_values] for INSERT.
render_table ( ) : string Renders part of the template: [table] Do not call directly.
render_table_noalias ( ) : string Returns template component [table_noalias].
render_where ( ) : string Renders [where].
replace ( ) Executes replace query.
reset ( ) Removes all definitions. Start from scratch.
rewind ( )
select ( ) Executes select query.
set ( string $field, mixed $value = UNDEFINED ) Sets field value for INSERT or UPDATE statements.
setCustom ( string | array $tag, string | object $value = null ) Defines a custom tag variable. WARNING: always backtick / escaped argument if it's unsafe.
sum ( string | object $arg ) : DB_dsql Creates expression for SUM().
table ( string $table = UNDEFINED, string $alias = UNDEFINED ) Specifies which table to use in this dynamic query. You may specify array to perform operation on multiple tables.
template ( string $template ) Explicitly sets template to your query. Remember to change $this->mode if you switch this.
truncate ( ) Executes truncate query.
update ( ) Executes update query.
useExpr ( string $expr, array $tags = [] ) Change template of existing query instead of creating new one. If unsure use expr().
valid ( )
where ( mixed $field, string $cond = UNDEFINED, string $value = UNDEFINED, string $kind = 'where' ) Adds condition to your query.

메소드 상세

SQLTemplate() 공개 메소드

By default it is in SELECT mode
public SQLTemplate ( string $mode )
$mode string A key for $this->sql_templates

__clone() 공개 메소드

public __clone ( )

__toString() 공개 메소드

Convert object to string - generate SQL expression
public __toString ( ) : string
리턴 string

_render() 공개 메소드

Helper for render(), which does the actual work.
public _render ( ) : string
리턴 string Resulting query

_render_where() 공개 메소드

Subroutine which renders either [where] or [having].
public _render_where ( string $kind ) : array
$kind string 'where' or 'having'
리턴 array Parsed chunks of query

_setArray() 공개 메소드

Internal method which can be used by simple param-giving methods such as option(), group(), etc.
public _setArray ( mixed $values, string $name, boolean $parse_commas = true )
$values mixed
$name string
$parse_commas boolean

_unique() 공개 메소드

{{{ Generic routines
public _unique ( &$array, $desired = null )

andExpr() 공개 메소드

Shortcut to produce expression for series of conditions concatinated with "and". Useful to be passed inside where() or join().
public andExpr ( ) : DB_dsql
리턴 DB_dsql New dynamic query, won't affect $this

args() 공개 메소드

set arguments for call(). Used by fx() and call() but you can use This with ->expr("in ([args])")->args($values);.
public args ( array $args )
$args array Array with mixed arguments

bt() 공개 메소드

Adds backtics around argument. This will allow you to use reserved SQL words as table or field names such as "table".
public bt ( mixed $s ) : string
$s mixed Any string or array of strings
리턴 string Quoted string

calcFoundRows() 공개 메소드

Use foundRows() to read this afterwards.
public calcFoundRows ( )

calc_found_rows() 공개 메소드

사용 중단: 4.3.2. Naming bug. Use foundRows() instead.
public calc_found_rows ( )

call() 공개 메소드

Sets a template for a user-defined method call with specified arguments.
public call ( string $fx, array $args = null )
$fx string Name of the user defined method
$args array Arguments in mixed form

concat() 공개 메소드

Return expression for concatinating multiple values Accepts variable number of arguments, all of them would be escaped.
public concat ( ) : DB_dsql
리턴 DB_dsql clone of $this

consume() 공개 메소드

If the argument is more likely to be a field, use tick=true.
public consume ( string | Field | DB_dsql $dsql, boolean $tick = true ) : string
$dsql string | Field | DB_dsql Expression
$tick boolean Preferred quoted style
리턴 string Quoted expression

count() 공개 메소드

Creates expression for COUNT().
public count ( string | object $arg = null ) : DB_dsql
$arg string | object Typically fieldname or expression of a sub-query
리턴 DB_dsql clone of $this

current() 공개 메소드

public current ( )

debug() 공개 메소드

This is identical to AbstractObject::debug(), but as an object will refer to the $owner. This is to avoid string-casting and messing up with the DSQL string.
public debug ( boolean | string $msg = true )
$msg boolean | string "true" to start debugging

del() 공개 메소드

Removes definition for argument. $q->del('where'), $q->del('fields') etc.
public del ( string $args )
$args string Could be 'field', 'where', 'order', 'limit', etc

delete() 공개 메소드

Executes delete query.
public delete ( )

describe() 공개 메소드

Creates a query for listing tables in databse-specific form Agile Toolkit DSQL does not pretend to know anything about model structure, so result parsing is up to you.
public describe ( string $table = null ) : DB_dsql
$table string Table
리턴 DB_dsql clone of $this

do_getAll() 공개 메소드

public do_getAll ( )

do_getAllHash() 공개 메소드

public do_getAllHash ( )

do_getHash() 공개 메소드

public do_getHash ( )

do_getOne() 공개 메소드

public do_getOne ( )

do_getRow() 공개 메소드

public do_getRow ( )

do_insert() 공개 메소드

사용 중단: 4.3.0 use insert()
public do_insert ( )

do_replace() 공개 메소드

사용 중단: 4.3.0 use replace()
public do_replace ( )

do_select() 공개 메소드

사용 중단: 4.3.0 use select()
public do_select ( )

do_update() 공개 메소드

사용 중단: 4.3.0 use update()
public do_update ( )

dsql() 공개 메소드

Create new dsql object linked with the same database connection and bearing same data-type. You can use this method to create sub-queries.
public dsql ( ) : DB_dsql
리턴 DB_dsql Empty query for same database

escape() 공개 메소드

Converts value into parameter and returns reference. Use only during query rendering. Consider using consume() instead.
public escape ( string $val ) : string
$val string String literal containing input data
리턴 string Safe and escapeed string

execute() 공개 메소드

Executes current query.
public execute ( )

expr() 공개 메소드

Returns new dynamic query and initializes it to use specific template.
public expr ( string $expr, array $tags = [] ) : DB_dsql
$expr string SQL Expression. Don't pass unverified input
$tags array Array of tags and values. @see setCustom()
리턴 DB_dsql New dynamic query, won't affect $this

fetch() 공개 메소드

Will execute the query (if it's not executed already) and return first row.
public fetch ( integer $mode = PDO::FETCH_ASSOC ) : mixed
$mode integer PDO fetch mode
리턴 mixed return result of PDO::fetch

fetchAll() 공개 메소드

public fetchAll ( )

field() 공개 메소드

Examples: $q->field('name'); Second argument specifies table for regular fields $q->field('name','user'); $q->field('name','user')->field('line1','address'); Array as a first argument will specify mulitple fields, same as calling field() multiple times $q->field(array('name','surname')); Associative array will assume that "key" holds the alias. Value may be object. $q->field(array('alias'=>'name','alias2'=>surname')); $q->field(array('alias'=>$q->expr(..), 'alias2'=>$q->dsql()->.. )); You may use array with aliases together with table specifier. $q->field(array('alias'=>'name','alias2'=>surname'),'user'); You can specify $q->expr() for calculated fields. Alias is mandatory. $q->field( $q->expr('2+2'),'alias'); // must always use alias You can use $q->dsql() for subqueries. Alias is mandatory. $q->field( $q->dsql()->table('x')... , 'alias'); // must always use alias
public field ( string | array $field, string $table = null, string $alias = null )
$field string | array Specifies field to select
$table string Specify if not using primary table
$alias string Specify alias for this field

fieldQuery() 공개 메소드

Removes all field definitions and returns only field you specify as parameter to this method. Original query is not affected ($this) Same as for field() syntax.
public fieldQuery ( string | array $field, string $table = null, string $alias = null ) : DB_dsql
$field string | array Specifies field to select
$table string Specify if not using primary table
$alias string Specify alias for this field
리턴 DB_dsql Clone of $this with only one field

foundRows() 공개 메소드

After fetching data, call this to find out how many rows there were in total. Call calcFoundRows() for better performance.
public foundRows ( ) : integer
리턴 integer number of results

fx() 공개 메소드

$q->fx('if', array($condition, $if_true, $if_false));
public fx ( string $fx, array $args = null )
$fx string Name of the built-in method
$args array Arguments

get() 공개 메소드

Will execute DSQL query and return all results inside array of hashes.
public get ( ) : array
리턴 array Array of associative arrays

getAll() 공개 메소드

public getAll ( )

getDebugQuery() 공개 메소드

Return formatted debug output.
public getDebugQuery ( string $r = null ) : string
$r string Rendered material
리턴 string SQL syntax of query

getField() 공개 메소드

Return expression containing a properly escaped field. Use make subquery condition reference parent query.
public getField ( string $fld ) : DB_dsql
$fld string Field in SQL table
리턴 DB_dsql Expression pointing to specified field

getHash() 공개 메소드

Will execute DSQL query and return first row as hash (column=>value).
public getHash ( ) : array
리턴 array Hash of next row in data stream

getOne() 공개 메소드

You can also simply cast your DSQL into string to get this value echo $dsql;
public getOne ( ) : string
리턴 string Value of first column in first row

getRow() 공개 메소드

Will execute DSQL query and return first row as array (not hash). If you call several times will return subsequent rows.
public getRow ( ) : array
리턴 array Next row of your data (not hash)

group() 공개 메소드

Implemens GROUP BY functionality. Simply pass either string field or expression.
public group ( string | object $group )
$group string | object Group by this

hasInsertOption() 공개 메소드

Check if specified insert option was previously added.
public hasInsertOption ( string $option ) : boolean
$option string Which option to check?
리턴 boolean

hasOption() 공개 메소드

Check if specified option was previously added.
public hasOption ( string $option ) : boolean
$option string Which option to check?
리턴 boolean

having() 공개 메소드

Same syntax as where().
public having ( mixed $field, string $cond = UNDEFINED, string $value = UNDEFINED )
$field mixed Field, array for OR or Expression
$cond string Condition such as '=', '>' or 'is not'
$value string Value. Will be quoted unless you pass expression

ignore() 공개 메소드

Sets IGNORE option.
public ignore ( )

insert() 공개 메소드

Executes insert query. Returns ID of new record.
public insert ( ) : integer
리턴 integer new record ID (from last_id)

insertAll() 공개 메소드

Inserts multiple rows of data. Uses ignore option AVOID using this, might not be implemented correctly.
public insertAll ( array $array ) : array
$array array Insert multiple rows into table with one query
리턴 array List of IDs

join() 공개 메소드

Examples: $q->join('address'); // on user.address_id=address.id $q->join('address.user_id'); // on address.user_id=user.id $q->join('address a'); // With alias $q->join(array('a'=>'address')); // Also alias Second argument may specify the field of the master table $q->join('address', 'billing_id'); $q->join('address.code', 'code'); $q->join('address.code', 'user.code'); Third argument may specify which kind of join to use. $q->join('address', null, 'left'); $q->join('address.code', 'user.code', 'inner'); Using array syntax you can join multiple tables too $q->join(array('a'=>'address', 'p'=>'portfolio')); You can use expression for more complex joins $q->join('address', $q->orExpr() ->where('user.billing_id=address.id') ->where('user.technical_id=address.id') )
public join ( string $foreign_table, mixed $master_field = null, string $join_kind = null, string $_foreign_alias = null )
$foreign_table string Table to join with
$master_field mixed Field in master table
$join_kind string 'left' or 'inner', etc
$_foreign_alias string Internal, don't use

key() 공개 메소드

public key ( )

limit() 공개 메소드

Limit how many rows will be returned.
public limit ( integer $cnt, integer $shift )
$cnt integer Number of rows to return
$shift integer Offset, how many rows to skip

next() 공개 메소드

public next ( )

option() 공개 메소드

Defines query option, such as DISTINCT.
public option ( string | expresion $option )
$option string | expresion Option to put after SELECT

option_insert() 공개 메소드

Defines insert query option, such as IGNORE.
public option_insert ( string | expresion $option )
$option string | expresion Option to put after INSERT

option_replace() 공개 메소드

Defines replace query option, such as IGNORE.
public option_replace ( string | expresion $option )
$option string | expresion Option to put after REPLACE

orExpr() 공개 메소드

Shortcut to produce expression which concatinates "where" clauses with "OR" operator.
public orExpr ( ) : DB_dsql
리턴 DB_dsql New dynamic query, won't affect $this

order() 공개 메소드

$q->order('name'); $q->order('name desc'); $q->order('name desc, id asc') $q->order('name',true);
public order ( mixed $order, string | boolean $desc = null )
$order mixed Order by
$desc string | boolean true to sort descending

paramBase() 공개 메소드

Change prefix for parametric values. Not really useful.
public paramBase ( string $param_base )
$param_base string prefix to use for param names

preexec() 공개 메소드

Execute query faster, but don't fetch data until iterating started. This can be done if you need to know foundRows() before fetching data.
public preexec ( )

random() 공개 메소드

Returns method for generating random numbers. This is used for ordering table in random order.
public random ( ) : DB_dsql
리턴 DB_dsql clone of $this

render() 공개 메소드

Converts query into string format. This will contain parametric references.
public render ( ) : string
리턴 string Resulting query

render_andwhere() 공개 메소드

Renders [andwhere].
public render_andwhere ( ) : string
리턴 string rendered SQL chunk

render_args() 공개 메소드

Renders [args].
public render_args ( ) : string
리턴 string rendered SQL chunk

render_field() 공개 메소드

Returns template component [field].
public render_field ( ) : string
리턴 string Parsed template chunk

render_from() 공개 메소드

Conditionally returns "from", only if table is Specified Do not call directly.
public render_from ( ) : string
리턴 string Parsed template chunk

render_fx() 공개 메소드

Renders [fx].
public render_fx ( ) : string
리턴 string rendered SQL chunk

render_group() 공개 메소드

Renders [group].
public render_group ( ) : string
리턴 string rendered SQL chunk

render_having() 공개 메소드

Renders [having].
public render_having ( ) : string
리턴 string rendered SQL chunk

render_join() 공개 메소드

Renders [join].
public render_join ( ) : string
리턴 string rendered SQL chunk

render_limit() 공개 메소드

Renders [limit].
public render_limit ( ) : string
리턴 string rendered SQL chunk

render_options() 공개 메소드

Renders [options].
public render_options ( ) : string
리턴 string rendered SQL chunk

render_options_insert() 공개 메소드

Renders [options_insert].
public render_options_insert ( ) : string
리턴 string rendered SQL chunk

render_options_replace() 공개 메소드

Renders [options_replace].
public render_options_replace ( ) : string
리턴 string rendered SQL chunk

render_order() 공개 메소드

Renders [order].
public render_order ( ) : string
리턴 string rendered SQL chunk

render_orwhere() 공개 메소드

Renders [orwhere].
public render_orwhere ( ) : string
리턴 string rendered SQL chunk

render_set() 공개 메소드

Renders [set] for UPDATE query.
public render_set ( ) : string
리턴 string rendered SQL chunk

render_set_fields() 공개 메소드

Renders [set_fields] for INSERT.
public render_set_fields ( ) : string
리턴 string rendered SQL chunk

render_set_values() 공개 메소드

Renders [set_values] for INSERT.
public render_set_values ( ) : string
리턴 string rendered SQL chunk

render_table() 공개 메소드

Renders part of the template: [table] Do not call directly.
public render_table ( ) : string
리턴 string Parsed template chunk

render_table_noalias() 공개 메소드

Returns template component [table_noalias].
public render_table_noalias ( ) : string
리턴 string Parsed template chunk

render_where() 공개 메소드

Renders [where].
public render_where ( ) : string
리턴 string rendered SQL chunk

replace() 공개 메소드

Executes replace query.
public replace ( )

reset() 공개 메소드

Removes all definitions. Start from scratch.
public reset ( )

rewind() 공개 메소드

public rewind ( )

select() 공개 메소드

Executes select query.
public select ( )

set() 공개 메소드

Sets field value for INSERT or UPDATE statements.
public set ( string $field, mixed $value = UNDEFINED )
$field string Name of the field
$value mixed Value of the field

setCustom() 공개 메소드

Defines a custom tag variable. WARNING: always backtick / escaped argument if it's unsafe.
public setCustom ( string | array $tag, string | object $value = null )
$tag string | array Corresponds to [tag] inside template
$value string | object Value for the template tag

sum() 공개 메소드

Creates expression for SUM().
public sum ( string | object $arg ) : DB_dsql
$arg string | object Typically fieldname or expression of a sub-query
리턴 DB_dsql clone of $this

table() 공개 메소드

Examples: $q->table('user'); $q->table('user','u'); $q->table('user')->table('salary') $q->table(array('user','salary')); $q->table(array('user','salary'),'user'); $q->table(array('u'=>'user','s'=>'salary')); If you specify multiple tables, you still need to make sure to add proper "where" conditions. All the above examples return $q (for chaining) You can also call table without arguments, which will return current table: echo $q->table(); If multiple tables are used, "false" is returned. Return is not quoted. Please avoid using table() without arguments as more tables may be dynamically added later.
public table ( string $table = UNDEFINED, string $alias = UNDEFINED )
$table string Specify table to use
$alias string Specify alias for the table

template() 공개 메소드

Explicitly sets template to your query. Remember to change $this->mode if you switch this.
public template ( string $template )
$template string New template to use by render

truncate() 공개 메소드

Executes truncate query.
public truncate ( )

update() 공개 메소드

Executes update query.
public update ( )

useExpr() 공개 메소드

Change template of existing query instead of creating new one. If unsure use expr().
public useExpr ( string $expr, array $tags = [] )
$expr string SQL Expression. Don't pass unverified input
$tags array Obsolete, use templates / setCustom()

valid() 공개 메소드

public valid ( )

where() 공개 메소드

Examples: $q->where('id',1); Second argument specifies table for regular fields $q->where('id>','1'); $q->where('id','>',1); You may use expressions $q->where($q->expr('a=b')); $q->where('date>',$q->expr('now()')); $q->where($q->expr('length(password)'),'>',5); Finally, subqueries can also be used $q->where('foo',$q->dsql()->table('foo')->field('name')); To specify OR conditions $q->where($q->orExpr()->where('a',1)->where('b',1)); you can also use the shortcut: $q->where(array('a is null','b is null'));
public where ( mixed $field, string $cond = UNDEFINED, string $value = UNDEFINED, string $kind = 'where' )
$field mixed Field, array for OR or Expression
$cond string Condition such as '=', '>' or 'is not'
$value string Value. Will be quoted unless you pass expression
$kind string Do not use directly. Use having()

프로퍼티 상세

$_iterating 공개적으로 프로퍼티

public $_iterating

$args 공개적으로 프로퍼티

Data accumulated by calling Definition methods, which is then used when rendering.
public array $args
리턴 array

$bt 공개적으로 프로퍼티

Backtics are added around all fields. Set this to blank string to avoid.
public string $bt
리턴 string

$data 공개적으로 프로퍼티

{{{ Iterator support
public $data

$debug 공개적으로 프로퍼티

Call $q->debug() to turn on debugging or $q->debug(false) to turn ir off.
public bool $debug
리턴 boolean

$default_exception 공개적으로 프로퍼티

Class name of default exception
public string $default_exception
리턴 string

$default_field 공개적으로 프로퍼티

If no fields are defined, this field is used.
public string|DB_dsql $default_field
리턴 string | DB_dsql

$extra_params 공개적으로 프로퍼티

Manually-specified params
public array $extra_params
리턴 array

$id_field 공개적으로 프로퍼티

Required for non-id based tables.
public string $id_field
리턴 string

$main_table 공개적으로 프로퍼티

Used to determine main table.
public bool|string $main_table
리턴 boolean | string

$mode 공개적으로 프로퍼티

Mode is initialized to "select" by default.
public string $mode
리턴 string

$output_mode 공개적으로 프로퍼티

When you convert this object to string, the following happens:
public string $output_mode
리턴 string

$owner 공개적으로 프로퍼티

Owner of this object
public $owner

$param_base 공개적으로 프로퍼티

Prefix for all parameteric variables: a, a_2, a_3, etc.
public string $param_base
리턴 string

$params 공개적으로 프로퍼티

List of PDO parametical arguments for a query. Used only during rendering.
public array $params
리턴 array

$preexec 공개적으로 프로퍼티

public $preexec

$sql_templates 공개적으로 프로퍼티

Templates are used to construct most common queries. Templates may be changed in vendor-specific implementation of dsql (extending this class).
public $sql_templates

$stmt 공개적으로 프로퍼티

PDO statement if query is prepared. Used by iterator.
public PDOStatement $stmt
리턴 PDOStatement

$template 공개적으로 프로퍼티

Expression to use when converting to string
public string $template
리턴 string