Database: ezcQueryUpdate
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcQueryUpdate
|
Class to create select database independent UPDATE queries. [
source]
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:
1. $q = ezcDbInstance::get()->createUpdateQuery();
2. $q->update( 'legends' )
3. ->set( 'Gretzky', 99 )
4. ->set( 'Lindros', 88 );
5. $stmt = $q->prepare();
6. $stmt->execute();
Parents
ezcQuery
|
--ezcQueryUpdate
Member Variables
|
protected string |
$whereString
= null
Stores the WHERE part of the SQL. |
Inherited Member Variables
From
ezcQuery:
Method Summary
|
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(
0 )
Adds a where clause with logical expressions to the query. |
Inherited Methods
From
ezcQuery :
Methods
__construct
ezcQueryUpdate __construct(
$db, [
$aliases = array()] )
Constructs a new ezcQueryUpdate that works on the database $db and with the aliases $aliases.
The parameters are passed directly to ezcQuery.
Parameters
| Name |
Type |
Description |
$db |
PDO |
|
$aliases |
array(string=>string) |
|
Redefinition of
| Method |
Description |
ezcQuery::__construct() |
Constructs a new ezcQuery that works on the database $db and with the aliases $aliases. |
getQuery
string getQuery(
)
Returns the query string for this query object.
Throws
| Class | Description |
ezcQueryInvalidException |
if no table or no values have been set. |
Redefinition of
set
The update query will set the column $column to the value $expression.
Parameters
| Name |
Type |
Description |
$column |
string |
|
$expression |
string |
|
update
Opens the query and sets the target table to $table.
update() returns a pointer to $this.
Parameters
| Name |
Type |
Description |
$table |
|
|
where
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.
Example:
1. $q->update( 'MyTable' )->where( $q->eq( 'id', 1 ) );
Parameters
| Name |
Type |
Description |
0 |
string|array(string) |
Either a string with a logical expression name or an array with logical expressions. |
Throws
| Class | Description |
ezcQueryException |
if called more than once. |
ezcQueryVariableParameterException |
if called with no parameters. |
Last updated: Fri, 02 Nov 2007