CreateStatement
MMO\pdo\statements · 1 symbol · generated 5 Oct 2026
CreateStatement
CreateStatement.php:36Ex1: $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;
- 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
clear()
CreateStatement.php:51| returns | self |
execute()
CreateStatement.php:85Same as Statement::execute, plus the statements of indexStatements once the table exists.
| returns | PDOStatement | the CREATE TABLE's |
fields($fields)
CreateStatement.php:126foreign($key, $ref)
CreateStatement.php:172Add 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).
| $key | array | string | the referencing column(s) |
| $ref | string | the referenced table and column(s), plus any trailing clause |
| returns | self |
fulltext($ids)
CreateStatement.php:154ifNotExists($value)
CreateStatement.php:193index($ids)
CreateStatement.php:138indexStatements($opts)
CreateStatement.php:99The 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.
isSqlite($opts)
CreateStatement.php:114options($opts)
CreateStatement.php:180primary($ids)
CreateStatement.php:130render($opts)
CreateStatement.php:67Same 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.
table($name)
CreateStatement.php:121temporary($value)
CreateStatement.php:189unique($ids)
CreateStatement.php:146__construct($handler, $table, $fields, $primary, $index)
CreateStatement.php:37Inherited members (50)
| Constants | Declared by | Description | |
|---|---|---|---|
ALL_FLAG | Statement | ||
CREATE_IF_NOT_EXISTS_FLAG | Statement | ||
CREATE_TEMPORARY_FLAG | Statement | ||
DELAYED_FLAG | Statement | ||
DISTINCT_FLAG | Statement | ||
DISTINCT_ROW_FLAG | Statement | ||
HIGH_PRIORITY_FLAG | Statement | ||
IF_EXISTS_FLAG | Statement | ||
IGNORE_FLAG | Statement | ||
LOW_PRIORITY_FLAG | Statement | ||
QUICK_FLAG | Statement | ||
STRAIGHT_JOIN_FLAG | Statement |
| Properties | Declared by | Description | |
|---|---|---|---|
content | Statement | ||
handler | Statement | ||
opts | Statement | ||
stmt | Statement | ||
template | Statement |
| Methods | Declared by | Description | |
|---|---|---|---|
addOptions($opts, $appendList) | Statement | Merge $opts into the existing options (through merge), rather than replacing them wholesale like setOptions. | |
bindValue($pdo, $index, $value, $type, $binds) | Statement | Bind one already-emitted value onto the PDO statement. | |
clearOptions() | Statement | Empty the options bag. | |
count() | Statement | \Countable::count | |
fetch($opt) | Statement | Fetch the first row of the query's result | |
fetchAll($clear) | Statement | Fetch all the result of a query | |
fetchAllObjects($class, $constructFirst, $args, $clear) | Statement | Fetch all the result of a query as Objects. | |
fetchObject($class, $constructFirst, $args) | Statement | Fetch the result of a query as an Object. | |
fetchValue($key) | Statement | Fetch the column's value of the first row of the query's result and advance fetch pointer | |
fetchValues($key) | Statement | Fetch 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() | Statement | Extract 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) | Statement | Load 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) | Statement | Prepare a PDO statement by binding values. | |
push($key, $fields) | Statement | ||
reset() | Statement | ||
rowCount() | Statement | ||
setOption($key, $value) | Statement | Set (or, with a null $value, remove) a single option. | |
setOptions($opts) | Statement | Replace the whole options bag. | |
SplitType($key) | Statement | Split a column:type key used by the INSERT/UPDATE value lists. | |
toArray() | Statement | Convert the content to a plain array, recursively converting any nested iArray value (e.g. | |
__toString() | Statement |