Home    Back    Forward    Refresh    txtSQL Homepage

createtable
Purpose: To create a txtSQL table inside a database
txtSQL >= 2.2.2 RC2
void createtable ( array ('table' => $tablename, 'columns' => $columns [, 'db' => $db]) )

This function will create a txtSQL table with the name $tablename, as long as it does not already exist. The columns that will be in this table will be defined in $columns part of the array. $columns must be an array in the following format

     array([$columnName => array([$coltype => $value]...)]... )

For more information on on column types, see the column types section

Important- To achieve the same results as this function before txtSQL 2.2.2 RC2, use the execute() function
Note- If $tablename already exists, txtSQL will issue an error
Note- If no $db is specified and no database is already selected, txtSQL will issue an error


Example 21: createtable() Copy to clipboard
<?php
$columns
= array('id'    => array('type' => 'int', 'auto_increment' => 1, 'permanent' => 1),
                 
'name'  => array('type' => 'string', 'max' => 50),
                 
'email' => array('type' => 'string', 'max' => 50)
                 );

$sql->createtable('db'      => 'testDb',
                  
'table'   => 'testTable',
                  
'columns' => $columns);
?>


User Comments - createtable
No comments posted yet;
Last Page Next Page

'Language Reference'

User Functions

Database Functions

Data Manipulation Functions

Table Functions
  • showtables
  • createtable
  • droptable
  • altertable
  • describe
  • table_count
  • emptyCache
  • table_exists
  • last_insert_id

    Error Handling Functions

    SQL Syntax

  • [ txtSQL Documentation powered by txtSQL | 6 SQL Queries ]