Get Started

Upgrade

Where Syntax

Query

Aggregation

Fetch

Transaction

Management

Advanced

Raw object

PDO object

Debug

Information

version: 2.1.12

create

Create a table.

create($table, $columns, $options)
Return: [PDOStatement] The PDOStatement object.

Basic Sample

Split every column definition into an array and will be combined.

$database->create("account", [
	"id" => [
		"INT",
		"NOT NULL",
		"AUTO_INCREMENT",
		"PRIMARY KEY"
	],
	"first_name" => [
		"VARCHAR(30)",
		"NOT NULL"
	]
]);
CREATE TABLE IF NOT EXISTS account (
	id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
	first_name VARCHAR(30) NOT NULL
)

Advanced

You can also set the raw string as column definition for additional options, it is supported <column_name> syntax for quotation shortcut.

$database->create("account", [
	"id" => [
		"INT",
		"NOT NULL",
		"AUTO_INCREMENT"
	],
	"email" => [
		"VARCHAR(70)",
		"NOT NULL",
		"UNIQUE"
	],
	"PRIMARY KEY (<id>)"
], [
	"ENGINE" => "MyISAM",
	"AUTO_INCREMENT" => 200
]);
CREATE TABLE IF NOT EXISTS account (
	id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
	email VARCHAR(70) NOT NULL UNIQUE,
	PRIMARY KEY (`id`)
)
ENGINE = MyISAM,
AUTO_INCREMENT = 200