Class tgcSqlBuilder_Insert

Description

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

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

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

tgcSqlBuilder
   |
   --tgcSqlBuilder_Insert
Method Summary
 tgcSqlBuilder_Insert tgcSqlBuilder_Insert (object &$dbc)
 mixed addInsert (mixed $colName, [mixed $value = null])
 mixed addRawInsert (mixed $colName, [mixed $value = null])
 void addTable (string $tableName)
 mixed generateQuery ()
 mixed removeInsert ([string $colName = null])
 mixed removeRawInsert ([string $colName = null])
 void removeTable ()
 void reset ()
Methods
Constructor tgcSqlBuilder_Insert (line 86)

Constructor

Constructor

  • access: public
tgcSqlBuilder_Insert tgcSqlBuilder_Insert (object &$dbc)
  • object $dbc: PEAR::DB connection object
addInsert (line 215)

Add a value to insert.

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


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

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

Add a raw INSERT statement

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


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

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

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_Select($dbc);
2 $sql->addTable('users');
3

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

Redefinition of:
tgcSqlBuilder::addTable()
Add the statements table.
generateQuery (line 104)

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_Insert($dbc);
2 $query = $sql->generateQuery();

  • return: sql-statement or PEAR_Error (possible error(s): SQLBUILDER_ERROR_NO_INSERT_VALUES)
  • access: public
mixed generateQuery ()

Redefinition of:
tgcSqlBuilder::generateQuery()
Generate the sql-statement.
removeInsert (line 246)

Remove one or all insert columns.

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

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

Remove one or all insert columns.

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

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

Remove the tablename.

Remove the tablename.

  • access: public
void removeTable ()

Redefinition of:
tgcSqlBuilder::removeTable()
Remove one or all tablename(s).
reset (line 347)

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.

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:03 +0100 by phpDocumentor 1.2.3