Personal tools
From wiki.swiftlytilting.com
Jump to: navigation, search

WinBinder Manual/db create table

Creates a table in the current database.

Syntax

bool db_create_table(string tablename, mixed fieldnames, mixed fieldattrib [, string idfield [, mixed valarray]])

Arguments

  • tablename is the name of the table to be created.
  • fieldnames is a set of identifiers that may be an array or a CSV string (without the "id" field).
  • fieldattrib is a set of fieldtypes that may be an array or a CSV string (without the "id" field).
  • idfield is the name of identifier field (column). idfield is also the auto-incrementing primary key. Default is "id".
  • valarray is a string with the values of the records desired. It may be an array or a CSV string.

Result

The result will be TRUE if the table was created or FALSE if the table already exists, could not be created or the records not be created.


Example

// Create table

echo "We create mytable with 2 records";
$fn = array("name", "what", "OK"); // fieldnames 
$fv[] = array("villa", " would like to live in", "0"); // valarray 
$fv[] = array("appartmenthouse", " there we are", "true"); 
$fa = array("text", "longtext", "bool"); // fieldattributs 
$res = db_create_table("mytable", $fn, $fa, "id", $fv); 
if ($res)
{ echo "mytable created with 2 records"; } 

See also


Winbinder Projects