Table of Contents

getTableCreate

API Package Subpackage Class Method Reference Last reviewed Doc status
API Home Package Joomla.Framework Subpackage Database Class JDatabase Method getTableCreate Reference getTableCreate() Never Work in Progress

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 ( $tables )

$tables array is an array of strings containing a list of table names.

Examples

Example

$database =& JFactory::getDBO();
$prefix = $database->_table_prefix;
$tables = array( $prefix.'content_frontpage', $prefix.'content_rating' );
$result = $database->getTableCreate( $tables );
print_r( $result );

might produce:

Result

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
        )
 
)