Class to create select database independent UPDATE queries.
ezcQueryUpdate does not support updating from via a select call.
Note that this class creates queries that are syntactically independant of database. Semantically the queries still differ and so the same query may produce different results on different databases. Such differences are noted throughout the documentation of this class.
This class implements SQL92. If your database differs from the SQL92 implementation extend this class and reimplement the methods that produce different results. Some methods implemented in ezcQuery are not defined by SQL92. These methods are marked and ezcQuery will return MySQL syntax for these cases.
The examples show the SQL generated by this class. Database specific implementations may produce different results.
Example:
Source for this file: /Database/src/sqlabstraction/query_update.php
ezcQuery | --ezcQueryUpdate
Version: | //autogentag// |
protected string |
$whereString
= null
Stores the WHERE part of the SQL. |
From ezcQuery | |
---|---|
protected |
ezcQuery::$db
|
public |
ezcQuery::$expr
|
public ezcQueryUpdate |
__construct(
$db
, [ $aliases
= array()] )
Constructs a new ezcQueryUpdate that works on the database $db and with the aliases $aliases. |
public string |
getQuery(
)
Returns the query string for this query object. |
public ezcQueryUpdate |
set(
$column
, $expression
)
The update query will set the column $column to the value $expression. |
public ezcQueryUpdate |
update(
$table
)
Opens the query and sets the target table to $table. |
public ezcQueryUpdate |
where(
$...
)
Adds a where clause with logical expressions to the query. |
From ezcQuery | |
---|---|
public ezcQuery |
ezcQuery::__construct()
Constructs a new ezcQuery that works on the database $db and with the aliases $aliases. |
public static array |
ezcQuery::arrayFlatten()
Returns all the elements in $array as one large single dimensional array. |
public string |
ezcQuery::bindParam()
Binds the parameter $param to the specified variable name $placeHolder.. |
public string |
ezcQuery::bindValue()
Binds the value $value to the specified variable name $placeHolder. |
public void |
ezcQuery::doBind()
Performs binding of variables bound with bindValue and bindParam on the statement $stmt. |
protected string |
ezcQuery::getIdentifier()
Returns the correct identifier for the alias $alias. |
protected array(string) |
ezcQuery::getIdentifiers()
Returns the correct identifiers for the aliases found in $aliases. |
public abstract string |
ezcQuery::getQuery()
Returns the query string for this query object. |
public bool |
ezcQuery::hasAliases()
Returns true if this object has aliases. |
public PDOStatement |
ezcQuery::prepare()
Returns a prepared statement from this query which can be used for execution. |
protected void |
ezcQuery::resetBinds()
Resets the bound values and parameters to empty. |
public void |
ezcQuery::setAliases()
Sets the aliases $aliases for this object. |
public ezcQuerySubSelect |
ezcQuery::subSelect()
Returns the ezcQuerySubSelect query object. |
public string |
ezcQuery::__toString()
Return SQL string for query. |
Constructs a new ezcQueryUpdate that works on the database $db and with the aliases $aliases.
The parameters are passed directly to ezcQuery.
Name | Type | Description |
---|---|---|
$db |
PDO | |
$aliases |
array(string=>string) |
Method | Description |
---|---|
ezcQuery::__construct() |
Constructs a new ezcQuery that works on the database $db and with the aliases $aliases. |
Returns the query string for this query object.
Type | Description |
---|---|
ezcQueryInvalidException |
if no table or no values have been set. |
Method | Description |
---|---|
ezcQuery::getQuery() |
Returns the query string for this query object. |
The update query will set the column $column to the value $expression.
Name | Type | Description |
---|---|---|
$column |
string | |
$expression |
string |
Opens the query and sets the target table to $table.
update() returns a pointer to $this.
Name | Type | Description |
---|---|---|
$table |
string |
Adds a where clause with logical expressions to the query.
where() accepts an arbitrary number of parameters. Each parameter must contain a logical expression or an array with logical expressions. If you specify multiple logical expression they are connected using a logical and. where() could be invoked several times. All provided arguments added to the end of $whereString and form final WHERE clause of the query.
Example:
Name | Type | Description |
---|---|---|
$... |
string|array(string) | Either a string with a logical expression name or an array with logical expressions. |
Type | Description |
---|---|
ezcQueryVariableParameterException |
if called with no parameters. |