Schema
extends AbstractSql
in package
Sql schema table class
Tags
Table of Contents
Constants
- BACKTICK = 'BACKTICK'
- Constants for id quote types
- BRACKET = 'BRACKET'
- DOUBLE_QUOTE = 'DOUBLE_QUOTE'
- MYSQL = 'MYSQL'
- Constants for database types
- NO_QUOTE = 'NO_QUOTE'
- PGSQL = 'PGSQL'
- SQLITE = 'SQLITE'
- SQLSRV = 'SQLSRV'
Properties
- $aggregateFunctions : array<string|int, mixed>
- Supported standard SQL aggregate functions
- $alter : array<string|int, mixed>
- ALTER table schema objects
- $closeQuote : string|null
- ID close quote
- $create : array<string|int, mixed>
- CREATE table schema objects
- $dateTimeFunctions : array<string|int, mixed>
- Supported standard SQL date-time functions
- $db : AbstractAdapter|null
- Database object
- $dbType : string|null
- Database type
- $drop : array<string|int, mixed>
- DROP table schema objects
- $foreignKeyCheck : bool
- Foreign key check flag
- $idQuoteType : string
- ID quote type
- $mathFunctions : array<string|int, mixed>
- Supported standard SQL math functions
- $openQuote : string|null
- ID open quote
- $parameterCount : int
- Parameter count
- $placeholder : string|null
- SQL placeholder
- $rename : array<string|int, mixed>
- RENAME table schema objects
- $stringFunctions : array<string|int, mixed>
- Supported standard SQL string functions
- $truncate : array<string|int, mixed>
- TRUNCATE table schema objects
Methods
- __construct() : mixed
- Constructor
- __toString() : string
- Render the schema to string
- alter() : Alter
- Access the ALTER table object
- create() : Create
- Access the CREATE table object
- createIfNotExists() : Create
- Access the CREATE table object, setting IF NOT EXISTS
- db() : AbstractAdapter|null
- Get the current database adapter object (alias method)
- decrementParameterCount() : AbstractSql
- Decrement parameter count
- disableForeignKeyCheck() : Schema
- Disable the foreign key check
- drop() : Drop
- Access the DROP table object
- dropIfExists() : Drop
- Access the DROP table object, setting IF EXISTS
- enableForeignKeyCheck() : Schema
- Enable the foreign key check
- execute() : void
- Execute the schema directly
- getCloseQuote() : string|null
- Get close quote
- getDb() : AbstractAdapter|null
- Get the current database adapter object
- getDbType() : string|null
- Get the current database type
- getIdQuoteType() : string
- Get the quote ID type
- getOpenQuote() : string|null
- Get open quote
- getParameter() : string
- Get parameter placeholder value
- getParameterCount() : int
- Get parameter count
- getPlaceholder() : string|null
- Get the SQL placeholder
- incrementParameterCount() : AbstractSql
- Increment parameter count
- isMysql() : bool
- Determine if the DB type is MySQL
- isParameter() : bool
- Check if value is parameter placeholder
- isPgsql() : bool
- Determine if the DB type is PostgreSQL
- isSqlite() : bool
- Determine if the DB type is SQLite
- isSqlsrv() : bool
- Determine if the DB type is SQL Server
- isSupportedFunction() : bool
- Check if value contains a standard SQL supported function
- quote() : float|int|string
- Quote the value (if it is not a numeric value)
- quoteId() : string
- Quote the identifier
- rename() : Rename
- Access the RENAME table object
- render() : string
- Render the schema
- reset() : Schema
- Reset and clear the schema object
- setIdQuoteType() : AbstractSql
- Set the quote ID type
- setPlaceholder() : AbstractSql
- Set the placeholder
- truncate() : Truncate
- Access the TRUNCATE table object
- getAlterTable() : Alter
- Get the ALTER table object
- getCreateTable() : Create
- Get the CREATE table object
- getDropTable() : Drop
- Get the DROP table object
- getRenameTable() : Rename
- Get the RENAME table object
- getTruncateTable() : Truncate
- Get the TRUNCATE table object
- init() : void
- Initialize SQL object
- initQuoteType() : void
- Initialize quite type
Constants
BACKTICK
Constants for id quote types
public
mixed
BACKTICK
= 'BACKTICK'
BRACKET
public
mixed
BRACKET
= 'BRACKET'
DOUBLE_QUOTE
public
mixed
DOUBLE_QUOTE
= 'DOUBLE_QUOTE'
MYSQL
Constants for database types
public
mixed
MYSQL
= 'MYSQL'
NO_QUOTE
public
mixed
NO_QUOTE
= 'NO_QUOTE'
PGSQL
public
mixed
PGSQL
= 'PGSQL'
SQLITE
public
mixed
SQLITE
= 'SQLITE'
SQLSRV
public
mixed
SQLSRV
= 'SQLSRV'
Properties
$aggregateFunctions
Supported standard SQL aggregate functions
protected
static array<string|int, mixed>
$aggregateFunctions
= ['AVG', 'COUNT', 'MAX', 'MIN', 'SUM']
$alter
ALTER table schema objects
protected
array<string|int, mixed>
$alter
= []
$closeQuote
ID close quote
protected
string|null
$closeQuote
= null
$create
CREATE table schema objects
protected
array<string|int, mixed>
$create
= []
$dateTimeFunctions
Supported standard SQL date-time functions
protected
static array<string|int, mixed>
$dateTimeFunctions
= ['CURRENT_DATE', 'CURRENT_TIMESTAMP', 'CURRENT_TIME', 'CURDATE', 'CURTIME', 'DATE', 'DATETIME', 'DAY', 'EXTRACT', 'GETDATE', 'HOUR', 'LOCALTIME', 'LOCALTIMESTAMP', 'MINUTE', 'MONTH', 'NOW', 'SECOND', 'TIME', 'TIMEDIFF', 'TIMESTAMP', 'UNIX_TIMESTAMP', 'YEAR']
$db
Database object
protected
AbstractAdapter|null
$db
= null
$dbType
Database type
protected
string|null
$dbType
= null
$drop
DROP table schema objects
protected
array<string|int, mixed>
$drop
= []
$foreignKeyCheck
Foreign key check flag
protected
bool
$foreignKeyCheck
= true
$idQuoteType
ID quote type
protected
string
$idQuoteType
= 'NO_QUOTE'
$mathFunctions
Supported standard SQL math functions
protected
static array<string|int, mixed>
$mathFunctions
= ['ABS', 'RAND', 'SQRT', 'POW', 'POWER', 'EXP', 'LN', 'LOG', 'LOG10', 'GREATEST', 'LEAST', 'DIV', 'MOD', 'ROUND', 'TRUNC', 'CEIL', 'CEILING', 'FLOOR', 'COS', 'ACOS', 'ACOSH', 'SIN', 'SINH', 'ASIN', 'ASINH', 'TAN', 'TANH', 'ATANH', 'ATAN2']
$openQuote
ID open quote
protected
string|null
$openQuote
= null
$parameterCount
Parameter count
protected
int
$parameterCount
= 0
$placeholder
SQL placeholder
protected
string|null
$placeholder
= null
$rename
RENAME table schema objects
protected
array<string|int, mixed>
$rename
= []
$stringFunctions
Supported standard SQL string functions
protected
static array<string|int, mixed>
$stringFunctions
= ['CONCAT', 'FORMAT', 'INSTR', 'LCASE', 'LEFT', 'LENGTH', 'LOCATE', 'LOWER', 'LPAD', 'LTRIM', 'POSITION', 'QUOTE', 'REGEXP', 'REPEAT', 'REPLACE', 'REVERSE', 'RIGHT', 'RPAD', 'RTRIM', 'SPACE', 'STRCMP', 'SUBSTRING', 'SUBSTR', 'TRIM', 'UCASE', 'UPPER']
$truncate
TRUNCATE table schema objects
protected
array<string|int, mixed>
$truncate
= []
Methods
__construct()
Constructor
public
__construct(AbstractAdapter $db) : mixed
Instantiate the SQL object
Parameters
- $db : AbstractAdapter
__toString()
Render the schema to string
public
__toString() : string
Return values
stringalter()
Access the ALTER table object
public
alter(string $table) : Alter
Parameters
- $table : string
Return values
Altercreate()
Access the CREATE table object
public
create(string $table) : Create
Parameters
- $table : string
Return values
CreatecreateIfNotExists()
Access the CREATE table object, setting IF NOT EXISTS
public
createIfNotExists(string $table) : Create
Parameters
- $table : string
Return values
Createdb()
Get the current database adapter object (alias method)
public
db() : AbstractAdapter|null
Return values
AbstractAdapter|nulldecrementParameterCount()
Decrement parameter count
public
decrementParameterCount() : AbstractSql
Return values
AbstractSqldisableForeignKeyCheck()
Disable the foreign key check
public
disableForeignKeyCheck() : Schema
Return values
Schemadrop()
Access the DROP table object
public
drop(string $table) : Drop
Parameters
- $table : string
Return values
DropdropIfExists()
Access the DROP table object, setting IF EXISTS
public
dropIfExists(string $table) : Drop
Parameters
- $table : string
Return values
DropenableForeignKeyCheck()
Enable the foreign key check
public
enableForeignKeyCheck() : Schema
Return values
Schemaexecute()
Execute the schema directly
public
execute([bool $reset = true ]) : void
Parameters
- $reset : bool = true
getCloseQuote()
Get close quote
public
getCloseQuote() : string|null
Return values
string|nullgetDb()
Get the current database adapter object
public
getDb() : AbstractAdapter|null
Return values
AbstractAdapter|nullgetDbType()
Get the current database type
public
getDbType() : string|null
Return values
string|nullgetIdQuoteType()
Get the quote ID type
public
getIdQuoteType() : string
Return values
stringgetOpenQuote()
Get open quote
public
getOpenQuote() : string|null
Return values
string|nullgetParameter()
Get parameter placeholder value
public
getParameter(mixed $value[, string|null $column = null ]) : string
Parameters
- $value : mixed
- $column : string|null = null
Return values
stringgetParameterCount()
Get parameter count
public
getParameterCount() : int
Return values
intgetPlaceholder()
Get the SQL placeholder
public
getPlaceholder() : string|null
Return values
string|nullincrementParameterCount()
Increment parameter count
public
incrementParameterCount() : AbstractSql
Return values
AbstractSqlisMysql()
Determine if the DB type is MySQL
public
isMysql() : bool
Return values
boolisParameter()
Check if value is parameter placeholder
public
isParameter(mixed $value[, string|null $column = null ]) : bool
Parameters
- $value : mixed
- $column : string|null = null
Return values
boolisPgsql()
Determine if the DB type is PostgreSQL
public
isPgsql() : bool
Return values
boolisSqlite()
Determine if the DB type is SQLite
public
isSqlite() : bool
Return values
boolisSqlsrv()
Determine if the DB type is SQL Server
public
isSqlsrv() : bool
Return values
boolisSupportedFunction()
Check if value contains a standard SQL supported function
public
static isSupportedFunction(string $value) : bool
Parameters
- $value : string
Return values
boolquote()
Quote the value (if it is not a numeric value)
public
quote([string|null $value = null ][, bool $force = false ]) : float|int|string
Parameters
- $value : string|null = null
- $force : bool = false
Return values
float|int|stringquoteId()
Quote the identifier
public
quoteId(string $identifier) : string
Parameters
- $identifier : string
Return values
stringrename()
Access the RENAME table object
public
rename(string $table) : Rename
Parameters
- $table : string
Return values
Renamerender()
Render the schema
public
render() : string
Return values
stringreset()
Reset and clear the schema object
public
reset() : Schema
Return values
SchemasetIdQuoteType()
Set the quote ID type
public
setIdQuoteType([string $type = self::NO_QUOTE ]) : AbstractSql
Parameters
- $type : string = self::NO_QUOTE
Return values
AbstractSqlsetPlaceholder()
Set the placeholder
public
setPlaceholder(string $placeholder) : AbstractSql
Parameters
- $placeholder : string
Return values
AbstractSqltruncate()
Access the TRUNCATE table object
public
truncate(string $table) : Truncate
Parameters
- $table : string
Return values
TruncategetAlterTable()
Get the ALTER table object
protected
getAlterTable(string $table) : Alter
Parameters
- $table : string
Return values
AltergetCreateTable()
Get the CREATE table object
protected
getCreateTable(string $table) : Create
Parameters
- $table : string
Return values
CreategetDropTable()
Get the DROP table object
protected
getDropTable(string $table) : Drop
Parameters
- $table : string
Return values
DropgetRenameTable()
Get the RENAME table object
protected
getRenameTable(string $table) : Rename
Parameters
- $table : string
Return values
RenamegetTruncateTable()
Get the TRUNCATE table object
protected
getTruncateTable(string $table) : Truncate
Parameters
- $table : string
Return values
Truncateinit()
Initialize SQL object
protected
init(string $adapter) : void
Parameters
- $adapter : string
initQuoteType()
Initialize quite type
protected
initQuoteType() : void