Index

CreateStatement

MMO\pdo\statements · 1 symbol · generated 5 Oct 2026

class

CreateStatement

CreateStatement.php:36

Ex1: $stmt = new CreateStatement($handler); $stmt->ifNotExists(); $stmt->temporary(); $stmt->table('test'); $stmt->fields(['id' => 'INT(3) UNSIGNED NOT NULL PRIMARY KEY', 'name' => 'VARCHAR(255) NOT NULL KEY']); $stmt->primary('id'); $stmt->index('name'); echo $stmt;

class MMO\pdo\statements\CreateStatement extends MMO\pdo\statements\Statement
Namespace
MMO\pdo\statements
Extends
Statement

Index

clear()
execute()Same as Statement::execute, plus the statements of indexStatements once the table exists.
fields($fields)
foreign($key, $ref)Add a table-level FOREIGN KEY (…) REFERENCES … constraint -- the form a composite key, or one carrying ON UPDATE/ON DELETE, needs.
fulltext($ids)
ifNotExists($value)
index($ids)
indexStatements($opts)The statements creating this table's indexes apart from the CREATE TABLE: SQLite takes no INDEX(…) inside one (near "INDEX": syntax error), so each indexed column gets its own `CREATE INDEX IF …
isSqlite($opts)
options($opts)
primary($ids)
render($opts)Same as Statement::render.
table($name)
temporary($value)
unique($ids)
__construct($handler, $table, $fields, $primary, $index)

Methods16

foreign($key, $ref)

CreateStatement.php:172

Add a table-level FOREIGN KEY (…) REFERENCES … constraint -- the form a composite key, or one carrying ON UPDATE/ON DELETE, needs. A single-column reference can also be written inline in the column's own definition (Field).

function foreign(array|string $key, string $ref): self
$keyarray | stringthe referencing column(s)
$refstringthe referenced table and column(s), plus any trailing clause
returnsself
$stmt->foreign(['author', 'date'], 'author(id, regDate) ON UPDATE CASCADE ON DELETE RESTRICT');

indexStatements($opts)

CreateStatement.php:99

The statements creating this table's indexes apart from the CREATE TABLE: SQLite takes no INDEX(…) inside one (near "INDEX": syntax error), so each indexed column gets its own CREATE INDEX IF NOT EXISTS <table>_<column>. Empty for MySQL, which declares them inline.

function indexStatements(array $opts = []): array
$opts = []array
returnsarray
$table->createStatement()->indexStatements(); // [CREATE INDEX IF NOT EXISTS `t_day` ON `t`(`day`)]

render($opts)

CreateStatement.php:67

Same as Statement::render. For SQLite, a table's one primary column, when it is AUTO_INCREMENT, is declared inline -- id INTEGER PRIMARY KEY AUTOINCREMENT -- without a PRIMARY KEY(id): SQLite takes the keyword nowhere else, and without it the id is the rowid, which gives the id of the highest row deleted to the next one.

function render(array $opts = []): stringNOTE: until 2026-09 it was `id INTEGER, …, PRIMARY KEY(id)`. A table created then still gives ids again: SQLite cannot add AUTOINCREMENT to a table (create another, copy the rows over).
$opts = []array
returnsstring
$table->createStatement()->render(['driver' => 'sqlite']); // CREATE TABLE `user` ( id INTEGER PRIMARY KEY AUTOINCREMENT, …)
Inherited members (50)
ConstantsDeclared byDescription
ALL_FLAGStatement
CREATE_IF_NOT_EXISTS_FLAGStatement
CREATE_TEMPORARY_FLAGStatement
DELAYED_FLAGStatement
DISTINCT_FLAGStatement
DISTINCT_ROW_FLAGStatement
HIGH_PRIORITY_FLAGStatement
IF_EXISTS_FLAGStatement
IGNORE_FLAGStatement
LOW_PRIORITY_FLAGStatement
QUICK_FLAGStatement
STRAIGHT_JOIN_FLAGStatement
PropertiesDeclared byDescription
contentStatement
handlerStatement
optsStatement
stmtStatement
templateStatement
MethodsDeclared byDescription
addOptions($opts, $appendList)StatementMerge $opts into the existing options (through merge), rather than replacing them wholesale like setOptions.
bindValue($pdo, $index, $value, $type, $binds)StatementBind one already-emitted value onto the PDO statement.
clearOptions()StatementEmpty the options bag.
count()Statement\Countable::count
fetch($opt)StatementFetch the first row of the query's result
fetchAll($clear)StatementFetch all the result of a query
fetchAllObjects($class, $constructFirst, $args, $clear)StatementFetch all the result of a query as Objects.
fetchObject($class, $constructFirst, $args)StatementFetch the result of a query as an Object.
fetchValue($key)StatementFetch the column's value of the first row of the query's result and advance fetch pointer
fetchValues($key)StatementFetch the column's value of all the row of the query's result
flag($key, $flag, $set)Statement
getIterator()Statement\IteratorAggregate::getIterator
getOption($key, $default)Statement
getOptions()Statement
getPDOStatement()Statement
getPlaceholders()StatementExtract placeholder from template
isEmpty()Statement
jsonSerialize()Statement\JsonSerializable::jsonSerialize -- the raw content is returned as-is (not recursively converted), so json_encode() relies on any nested iArray values being JsonSerializable themselves.
keys()Statement
loadArray($data)StatementLoad every entry of a plain array into the content, through offsetSet (so any offsetSet() override defined by the class using this trait, e.g.
offsetExists($key)Statement\ArrayAccess::offsetExists
offsetGet($key)Statement\ArrayAccess::offsetGet
offsetSet($key, $value)Statement\ArrayAccess::offsetSet -- a null $key appends ($bag[] = $value), like a plain PHP array.
offsetUnset($key)Statement\ArrayAccess::offsetUnset -- on a list (sequential integer keys, as produced by $bag[] = ...), the element is spliced out (closing the gap and reindexing), matching \unset() semantics on a plain …
prepare($binds, $sql)StatementPrepare a PDO statement by binding values.
push($key, $fields)Statement
reset()Statement
rowCount()Statement
setOption($key, $value)StatementSet (or, with a null $value, remove) a single option.
setOptions($opts)StatementReplace the whole options bag.
SplitType($key)StatementSplit a column:type key used by the INSERT/UPDATE value lists.
toArray()StatementConvert the content to a plain array, recursively converting any nested iArray value (e.g.
__toString()Statement