v5:dictionary:changetablesql
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
dictionary:changetablesql [2015/09/16 01:15] – created mnewnham | dictionary:changetablesql [2015/09/16 01:19] – [Description] mnewnham | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== changeTableSql ====== | ||
+ | ~~NOTOC~~ | ||
+ | <WRAP right box> | ||
+ | == See Also == | ||
+ | |||
+ | [[dictionary: | ||
+ | [[dictionary: | ||
+ | |||
+ | == Syntax == | ||
+ | array changeTableSql ( | ||
+ | string $tableName, | ||
+ | string $fields, | ||
+ | optional array $tableOptions=false, | ||
+ | optional bool $dropColumns=false | ||
+ | ) | ||
+ | </ | ||
+ | ===== Description ===== | ||
+ | The method '' | ||
+ | |||
+ | ===== Parameters ===== | ||
+ | ==== $tableName ===== | ||
+ | The table name must not yet exist in the database. Names must conform to any database specific requirements such as length limitations and name casing. | ||
+ | --------- | ||
+ | <WRAP right tip 200px> | ||
+ | $fields is a string, not an array | ||
+ | </ | ||
+ | ==== $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: | ||
+ | ==== $tableOptions ==== | ||
+ | An optional array of information that adds information regarding the table creation. This array may also contain field specific information, | ||
+ | ==== $dropColumns ==== | ||
+ | By default, any columns not specified in the '' | ||
+ | ===== Usage ===== | ||
+ | <code php> | ||
+ | /* | ||
+ | * create a data dictionary object, using the database connection | ||
+ | */ | ||
+ | $dict = NewDataDictionary($db); | ||
+ | |||
+ | $tabname = " | ||
+ | /* | ||
+ | * Change the length of COL1 from 32 chars to 60 | ||
+ | */ | ||
+ | |||
+ | $flds = " | ||
+ | COL1 C(60) NOTNULL DEFAULT ' | ||
+ | "; | ||
+ | |||
+ | /* | ||
+ | * create the SQL statement necessary to create the table and its columns | ||
+ | */ | ||
+ | $sqlarray = $dict-> | ||
+ | |||
+ | /* | ||
+ | * This returns (for DB2) | ||
+ | Array | ||
+ | ( | ||
+ | [0] => ALTER TABLE LCTABLE ALTER COLUMN COL1 SET DATA TYPE VARCHAR(60) DEFAULT ' | ||
+ | ) | ||
+ | */ | ||
+ | |||
+ | |||
+ | /* | ||
+ | * This statement actually creates the table | ||
+ | */ | ||
+ | $dict-> | ||
+ | </ | ||
v5/dictionary/changetablesql.txt · Last modified: 2016/03/20 23:33 by mnewnham