v5:dictionary:createtablesql
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
dictionary:createtablesql [2015/08/23 22:13] – created mnewnham | v5:dictionary:createtablesql [2016/03/05 01:55] (current) – [$tableOptions] mnewnham | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== createTableSql ====== | ====== createTableSql ====== | ||
+ | ~~NOTOC~~ | ||
<WRAP right box> | <WRAP right box> | ||
== See Also == | == See Also == | ||
- | [[dictionary: | + | |
+ | [[v5: | ||
+ | |||
+ | [[v5:dictionary:executesqlarray|executeSqlArray()]] | ||
== Syntax == | == Syntax == | ||
- | | + | |
string $tableName, | string $tableName, | ||
string $fields, | string $fields, | ||
Line 12: | Line 16: | ||
</ | </ | ||
===== Description ===== | ===== Description ===== | ||
- | The method '' | + | The method '' |
===== Parameters ===== | ===== Parameters ===== | ||
==== $tableName ===== | ==== $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. | 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 ==== | ==== $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: | + | 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: |
==== $tableOptions ==== | ==== $tableOptions ==== | ||
- | An optional array of information that adds information regarding the table creation. This array may also contain field specific information, | + | An optional array of information that adds information regarding the table creation. This array may also contain field specific information, |
- | ===== Usage ===== | ||
<code php> | <code php> | ||
+ | $tabname = ' | ||
+ | $flds = ' | ||
+ | $opts = array(' | ||
+ | ' | ||
- | # Then create a data dictionary object, using this connection | + | $sql = $db-> |
+ | </ | ||
+ | |||
+ | In the example above, the values provided in '' | ||
+ | ===== Usage ===== | ||
+ | <code php> | ||
+ | /* | ||
+ | * create a data dictionary object, using the database | ||
+ | */ | ||
$dict = NewDataDictionary($db); | $dict = NewDataDictionary($db); | ||
Line 37: | Line 57: | ||
/* | /* | ||
- | * create the SQL statement necessary to create the table | + | * create the SQL statement necessary to create the table and its columns |
*/ | */ | ||
$sqlarray = $dict-> | $sqlarray = $dict-> | ||
+ | |||
+ | /* | ||
+ | * This returns (for DB2) | ||
+ | Array | ||
+ | ( | ||
+ | [0] => CREATE TABLE UCTABLE ( | ||
+ | | ||
+ | | ||
+ | | ||
+ | ) | ||
+ | ) | ||
+ | */ | ||
+ | |||
/* | /* | ||
Line 45: | Line 78: | ||
*/ | */ | ||
$dict-> | $dict-> | ||
- | </ | ||
</ | </ | ||
v5/dictionary/createtablesql.txt · Last modified: 2016/03/05 01:55 by mnewnham