[REVIEW] database->getTableCreate

Last reviewed: Not reviewed
phpDocumentor

database->getTableCreate

Generates the SQL code that would be required to create new (empty) tables exactly like the ones specified.  Returns an array of SQL 'CREATE TABLE' statements.

Syntax

array getTableCreate ( array $tables )

$tablesis an array of table names for which SQL statements are to be generated.

Examples

Example:

function generateSQL() {
  global $database;
 
  $prefix = $database->_table_prefix;
  $tables = array( $prefix.'content_frontpage', $prefix.'content_rating' );
  $result = $database->getTableCreate( $tables );
  print_r( $result );
}
 
generateSQL();

might produce:

Array
(
    [jos_content_frontpage] => Array
        (
            [0] => CREATE TABLE `jos_content_frontpage` (
  `content_id` int(11) NOT NULL default '0',
  `ordering` int(11) NOT NULL default '0',
  PRIMARY KEY  (`content_id`)
) TYPE=MyISAM
        )
 
    [jos_content_rating] => Array
        (
            [0] => CREATE TABLE `jos_content_rating` (
  `content_id` int(11) NOT NULL default '0',
  `rating_sum` int(11) unsigned NOT NULL default '0',
  `rating_count` int(11) unsigned NOT NULL default '0',
  `lastip` varchar(50) NOT NULL default '',
  PRIMARY KEY  (`content_id`)
) TYPE=MyISAM
        )
 
)

Please report any errors on this page to the Developer Documentation Forum

Last Updated ( Monday, 25 December 2006 )