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
Next revisionBoth sides next revision
dictionary:createtablesql [2015/08/24 01:31] mnewnhamdictionary:createtablesql [2015/08/26 00:56] mnewnham
Line 1: Line 1:
 ====== createTableSql ====== ====== createTableSql ======
 +~~NOTOC~~
 <WRAP right box> <WRAP right box>
 == See Also == == See Also ==
Line 12: Line 13:
 </WRAP> </WRAP>
 ===== Description ===== ===== Description =====
-The method ''createTableSql()'' creates a new table in the database and populates it with columns defined in ''$fields'' option.+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. 
 ===== Parameters ===== ===== Parameters =====
 ==== $tableName ===== ==== $tableName =====
Line 23: Line 25:
 ===== Usage ===== ===== Usage =====
 <code php> <code php>
- +/* 
- +create a data dictionary object, using the database connection 
-# Then create a data dictionary object, using this connection+*/
 $dict = NewDataDictionary($db); $dict = NewDataDictionary($db);
  
Line 37: Line 39:
  
 /* /*
-* create the SQL statement necessary to create the table+* create the SQL statement necessary to create the table and its columns
 */ */
 $sqlarray = $dict->createTableSQL($tabname, $flds); $sqlarray = $dict->createTableSQL($tabname, $flds);
 +
 +/*
 + * This returns (for DB2)
 +Array
 +(
 +    [0] => CREATE TABLE UCTABLE (
 +           COL1         VARCHAR(32) DEFAULT 'abc' NOT NULL,
 +           COL2         INTEGER DEFAULT 0,
 +           COL3         DECIMAL(12,2)
 +           )
 +)
 +*/
 +
  
 /* /*
v5/dictionary/createtablesql.txt · Last modified: 2016/03/05 01:55 by mnewnham