ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:dictionary:createtablesql

This is an old revision of the document!


createTableSql

See Also

addColumnSql()

Syntax
string createTableSql (
    string $tableName,
    string $fields,
    optional array $tableOptions
    )

Description

The method createTableSql() creates a new table in the database and populates it with columns defined in $fields option.

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.

$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 addColumnSql().

$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.

Usage

 
# Then create a data dictionary object, using this connection
$dict = NewDataDictionary($db);
 
$tabname = "UCTABLE";
 
$flds = " 
   COL1 C(32) NOTNULL DEFAULT 'abc',
   COL2 I  DEFAULT 0,
   COL3 N(12.2)
  ";
 
/*
* create the SQL statement necessary to create the table
*/
$sqlarray = $dict->createTableSQL($tabname, $flds);
 
/*
* This statement actually creates the table
*/
$dict->executeSqlArray($sqlarray);

</code>

v5/dictionary/createtablesql.1440360798.txt.gz · Last modified: 2017/04/21 11:28 (external edit)