Class tgcSqlBuilder_Update

Description

Subclass of tgcSqlBuilder that helps to create UPDATE sql-statements.

Subclass of tgcSqlBuilder that helps to create UPDATE sql-statements.

Located in /tgcSqlBuilder/Update.php (line 31)

tgcSqlBuilder
   |
   --tgcSqlBuilder_Update
Method Summary
 tgcSqlBuilder_Update tgcSqlBuilder_Update (object &$dbc)
 mixed addRawUpdate (mixed $colName, [mixed $value = null])
 void addRawWhere (string $statement, [mixed $logic = SQLBUILDER_LOGICAL_AND])
 void addTable (string $tableName)
 mixed addUpdate (mixed $colName, [mixed $value = null])
 void addWhere (string $table, string $column, mixed $value, [string $compOp = null], [string $logic = null])
 string generateQuery ()
 mixed removeRawUpdate ([string $colName = null])
 boolean removeRawWhere ([string $logic = null])
 void removeTable ()
 mixed removeUpdate ([string $colName = null])
 mixed removeWhere ([string $table = null], [string $column = null], [string $logic = null])
 void reset ()
 void setLimit (int $rows, int $offset)
 void unsetLimit ()
Methods
Constructor tgcSqlBuilder_Update (line 154)

Constructor

Constructor

  • access: public
tgcSqlBuilder_Update tgcSqlBuilder_Update (object &$dbc)
  • object $dbc: PEAR::DB connection object
addRawUpdate (line 439)

Add a raw UPDATE statement

Add a raw UPDATE statement There are two ways of calling this method:


1 // simple method-call
2 $sql = new tgcSqlBuilder_Update($dbc);
3 $sql->addUpdate('creationTime', 'NOW()');
4
5 // complex method-call, you can add more than one insert with only one method-call
6 $update = array (
7 'created' => 'NOW()',
8 'changed' => 'NOW()'
9 );
10 $sql->addUpdate($update);

  • return: true on success, else PEAR_Error (possible error(s): SQLBUILDER_ERROR_INVALID_PARAM_COMBO)
  • access: public
mixed addRawUpdate (mixed $colName, [mixed $value = null])
  • mixed $colName: columnname or associative array containing pairs of $colName => $value
  • mixed $value: value to insert
addRawWhere (line 515)

Add a raw WHERE statement.

Add a raw WHERE statement. You can add a raw WHERE statement and define a logical operator. As default this is the logical AND.

  • access: public
void addRawWhere (string $statement, [mixed $logic = SQLBUILDER_LOGICAL_AND])
  • string $statement: raw WHERE statement@ param string $logic SQLBUILDER_LOGICAL_AND or SQLBUILDER_LOGICAL_OR
addTable (line 257)

Add the statements table.

Add the statements table. If you call this method twice, the tablename that was set in first call will be overwritten.


1 $sql = new tgcSqlBuilder_Update($dbc);
2 $sql->addTable('users');
3

  • access: public
void addTable (string $tableName)
  • string $tableName: tablename

Redefinition of:
tgcSqlBuilder::addTable()
Add the statements table.
addUpdate (line 364)

Add a value to update.

Add a value to update. There are two ways of calling this method:


1 // simple method-call
2 $sql = new tgcSqlBuilder_Update($dbc);
3 $sql->addUpdate('col_Username', 'superman');
4
5 // complex method-call, you can add more than one update with only one method-call
6 $update = array (
7 'col_Username' => 'superman',
8 'col_Email' => 'superman@superheroes.com'
9 );
10 $sql->addUpdate($update);

  • return: true on success, else PEAR_Error (possible error(s): SQLBUILDER_ERROR_INVALID_PARAM_COMBO)
  • access: public
mixed addUpdate (mixed $colName, [mixed $value = null])
  • mixed $colName: columnname or associative array containing pairs of $colName => $value
  • mixed $value: value to update
addWhere (line 319)

Add a WHERE statement.

Add a WHERE statement. Possible comparison operators are: SQLBUILDER_COMP_EQUAL, SQLBUILDER_COMP_NOT_EQUAL, SQLBUILDER_COMP_LESSER_THAN, SQLBUILDER_COMP_LESSER_EQUAL, SQLBUILDER_COMP_GREATER_EQUAL, SQLBUILDER_COMP_GREATER_THAN, SQLBUILDER_COMP_STARTSWITH, SQLBUILDER_COMP_CONTAINS, SQLBUILDER_COMP_ENDSWITH, SQLBUILDER_COMP_BETWEEN If none is specified then SQLBUILDER_COMP_EQUAL will be used. Possible logical expressions are: SQLBUILDER_LOGICAL_AND, SQLBUILDER_LOGICAL_OR If none is specified, then SQLBUILDER_LOGICAL_AND will be used. When you are using SQLBUILDER_COMP_BETWEEN, then specify $values as a numerical array with two values in correct order.

  • access: public
void addWhere (string $table, string $column, mixed $value, [string $compOp = null], [string $logic = null])
  • string $table: tablename
  • string $column: columnname
  • mixed $value: value(s)
  • string $compOp: comparison operator
  • string $logic: logical linkup
generateQuery (line 172)

Generate the sql-statement.

Generate the sql-statement. This method generates a query based on the object-information and returns it as a string.


1 $sql = new tgcSqlBuilder_Update($dbc);
2 $query = $sql->generateQuery();

  • return: sql-statement
  • access: public
string generateQuery ()

Redefinition of:
tgcSqlBuilder::generateQuery()
Generate the sql-statement.
removeRawUpdate (line 470)

Remove one or all UPDATE columns.

Remove one or all UPDATE columns. If you specify a columnname, then just this column's UPDATE will be removed, else all UPDATEs will be removed.

  • return: true on success, else PEAR_Error (possible error(s): SQLBUILDER_ERROR_COLUMN_DOES_NOT_EXIST)
  • access: public
mixed removeRawUpdate ([string $colName = null])
  • string $colName: columnname
removeRawWhere (line 527)

Remove the raw WHERE statements, that have been stored so far.

Remove the raw WHERE statements, that have been stored so far.

  • return: true on success, else PEAR_Error
  • access: public
boolean removeRawWhere ([string $logic = null])
  • string $logic: SQLBUILDER_LOGICAL_AND or SQLBUILDER_LOGICAL_OR
removeTable (line 267)

Remove the tablename.

Remove the tablename.

  • access: public
void removeTable ()

Redefinition of:
tgcSqlBuilder::removeTable()
Remove one or all tablename(s).
removeUpdate (line 395)

Remove one or all update columns.

Remove one or all update columns. If you specify a columnname, then just this column's update will be removed, else all updates will be removed.

  • return: true on success, else PEAR_Error (possible error(s): SQLBUILDER_ERROR_COLUMN_DOES_NOT_EXIST)
  • access: public
mixed removeUpdate ([string $colName = null])
  • string $colName: columnname
removeWhere (line 336)

Remove a WHERE statement.

Remove a WHERE statement. If you don't specify any parameter, then all WHERE information will be removed. If you specify a tablename and a columnname, then this specific ORDER BY setting will be removed.

  • return: true on success or PEAR_Error (possible error(s): SQLBUILDER_ERROR_INVALID_PARAM_COMBO)
  • access: public
mixed removeWhere ([string $table = null], [string $column = null], [string $logic = null])
  • string $table: tablename
  • string $column: columnname
  • string $logic: logical operation (possible values: SQLBUILDER_LOGICAL_AND, SQLBUILDER_LOGICAL_OR)
reset (line 496)

Reset the object's whole information.

Reset the object's whole information.

  • access: public
void reset ()

Redefinition of:
tgcSqlBuilder::reset()
Reset the object's whole information.
setLimit (line 279)

Set the LIMIT for the sql-statement.

Set the LIMIT for the sql-statement.

  • access: public
void setLimit (int $rows, int $offset)
  • int $offset: offset
  • int $rows: rows
unsetLimit (line 289)

Remove the LIMIT for the sql-statement.

Remove the LIMIT for the sql-statement.

  • access: public
void unsetLimit ()

Inherited Methods

Inherited From tgcSqlBuilder

 tgcSqlBuilder::tgcSqlBuilder()
 tgcSqlBuilder::addTable()
 tgcSqlBuilder::escape()
 tgcSqlBuilder::generateQuery()
 tgcSqlBuilder::removeTable()
 tgcSqlBuilder::reset()

Documentation generated on Fri, 19 Nov 2004 23:54:06 +0100 by phpDocumentor 1.2.3