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 revision Previous revision
Next revision
Previous revision
v5:dictionary:createtablesql [2015/08/26 01:04]
mnewnham
v5:dictionary:createtablesql [2016/03/05 01:55] (current)
mnewnham [$tableOptions]
Line 3: Line 3:
 <WRAP right box> <WRAP right box>
 == See Also == == See Also ==
-[[dictionary:addcolumnsql|addColumnSql()]]+ 
 +[[v5:dictionary:column_attributes|Column Attributes Reference]]  
 + 
 +[[v5:dictionary:executesqlarray|executeSqlArray()]]
  
 == Syntax == == Syntax ==
Line 13: 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 23: 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.1440543882.txt.gz · Last modified: 2017/04/21 11:28 (external edit)