ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:dictionary:createtablesql

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
v5:dictionary:createtablesql [2016/01/13 02:06] – ↷ Page moved from dictionary:createtablesql to v5:dictionary:createtablesql mnewnhamv5:dictionary:createtablesql [2016/03/05 01:55] (current) – [$tableOptions] mnewnham
Line 4: Line 4:
 == See Also == == See Also ==
  
-[[dictionary:column_attributes|Column Attributes Reference]] +[[v5:dictionary:column_attributes|Column Attributes Reference]] 
  
-[[dictionary:executesqlarray|executeSqlArray()]]+[[v5:dictionary:executesqlarray|executeSqlArray()]]
  
 == Syntax == == Syntax ==
Line 16: Line 16:
 </WRAP> </WRAP>
 ===== Description ===== ===== Description =====
-The method ''createTableSql()'' creates the SQL statement necessary to create a table in the database and populates it with columns defined in ''$fields'' option. In order to create the table, the output of the command must be executed with the [[dictionary:executesqlarray|executeSqlArray()]] method.+The method ''createTableSql()'' creates the SQL statement necessary to create a table in the database and populates it with columns defined in ''$fields'' option. In order to create the table, the output of the command must be executed with the [[v5:dictionary:executesqlarray|executeSqlArray()]] method.
  
 ===== Parameters ===== ===== Parameters =====
Line 26: Line 26:
 </WRAP> </WRAP>
 ==== $fields ==== ==== $fields ====
-A string holding information regarding the columns to create in the new table. For a detailed description of the format of this string, see [[dictionary:addcolumnsql|addColumnSql()]].+A string holding information regarding the columns to create in the new table. For a detailed description of the format of this string, see [[v5:dictionary:addcolumnsql|addColumnSql()]].
 ==== $tableOptions ==== ==== $tableOptions ====
-An optional array of information that adds information regarding the table creation. This array may also contain field specific information, for example information pertaining to auto-increment fields.+An optional array of information that adds information regarding the table creation. This array may also contain field specific information, for example information pertaining to auto-increment fields. Another feature of this option is that it can be used to provide database specific options to the table itself, e.g.
  
 +<code php>
 +
 +$tabname = 'TEST';
 +$flds    = 'column definitions....';
 +$opts    = array('MYSQL'=>"ENGINE INNODB,COMPRESSION 'ZLIB'",
 +                 'DB2'=>'TABLESPACE LARGE_SPACE');
 +
 +$sql = $db->createTableSql($tabname,$flds,$opts);
 +</code>
 +
 +In the example above, the values provided in ''$opts'' will be added to the table if the **data provider** matches that of the currently attached database.
 ===== Usage ===== ===== Usage =====
 <code php> <code php>
v5/dictionary/createtablesql.1452647167.txt.gz · Last modified: 2017/04/21 11:28 (external edit)