yana

phpDocumentor v 1.4.0

Class DbCreator

Description

«decorator» database Creator
This decorator class is intended to create SQL DDL (data definition language) from YANA Framework - database structure files.
For this task it provides functions which create specific DDL for various DBS.
  • since: 2.8.6
  • access: public
Object
   |
   --DbCreator
Method Summary

Direct descendents

Class Description
DbExtractor «decorator» database Extractor

Methods

create a new instance
DbCreator DbCreator (
string|DbStructure &$structure
)
List of parameters:
Name Type Description
&$structure string|DbStructure a structure resource
Description:
This class requires an object of class DbStructure as input.
Example of usage:
  1.  // create new instance of this class
  2.  $dbc new DbCreatornew DbStructure('guestbook'));
  3.  // since version 2.9.6 you may also write
  4.  $db 'guestbook';
  5.  $dbc new DbCreator($db);
  6.  // create SQL DDL (here: using MySQL syntax)
  7.  $arrayOfStmts $dbc->createMySQL();
  8.  // This will output the result as text
  9.  print implode("\n"$arrayOfStmts);
  10.  // This will send the statements to the database
  11.  $db new DbStream('guestbook');
  12.  foreach ($arrayOfStmts as $stmt)
  13.  {
  14.     $db->query($stmt);
  15.  }
create SQL for IBM DB2
array createDB2 ()
Description:
Returns a numeric array of SQL statements. Each element is a single statement. If you want to send the result to a SQL file you should "implode()" the array to a string.
  • access: public

Redefined in descendants as:
create SQL for MS Access
array createMSAccess ()
Description:
Same as DbCreator::createMSSQL()

Redefined in descendants as:
create SQL for MS SQL Server
array createMSSQL ()
Description:
Returns a numeric array of SQL statements. Each element is a single statement. If you want to send the result to a SQL file you should "implode()" the array to a string.
  • access: public

Redefined in descendants as:
create SQL for MySQL
array createMySQL ()
Description:
Returns a numeric array of SQL statements. Each element is a single statement. If you want to send the result to a SQL file you should "implode()" the array to a string.
  • access: public

Redefined in descendants as:
create SQL for Oracle
array createOracleDB ()
Description:
Returns a numeric array of SQL statements. Each element is a single statement. If you want to send the result to a SQL file you should "implode()" the array to a string.
  • access: public

Redefined in descendants as:
create SQL for PostgreSQL
array createPostgreSQL ()
Description:
Returns a numeric array of SQL statements. Each element is a single statement. If you want to send the result to a SQL file you should "implode()" the array to a string.
  • access: public

Redefined in descendants as:
get the currently set structure file
DbStructure getStructure ()
Description:
Returns an instance of {link DbStructure}. You can query this object for details on the structure of the currently selected database.
  • since: 2.9.6
  • access: public
set a new structure file
bool setStructure (
string|DbStructure &$structure
)
List of parameters:
Name Type Description
&$structure string|DbStructure
Description:
The argument $structure may either be a reference to an instance of class DbStructure, or a string, which contains the name of a database. The database must be registered in the framework. If so, this function may find the corresponding structure file automatically.
Returns bool(true) on success or bool(false) on error.
  • since: 2.9.6
  • access: public
inherited from base classes

Inherited From Object

Documentation generated on Sat, 03 Jan 2009 22:22:16 +0100 by phpDocumentor 1.4.0

yana author: Thomas MeyerHomepage: www.yanaframework.net