Truncate
extends AbstractTable
in package
Schema TRUNCATE 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
- $cascade : bool
- CASCADE flag
- $closeQuote : string|null
- ID close quote
- $dateTimeFunctions : array<string|int, mixed>
- Supported standard SQL date-time functions
- $db : AbstractAdapter|null
- Database object
- $dbType : string|null
- Database type
- $idQuoteType : string
- ID quote type
- $info : array<string|int, mixed>
- Table info
- $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
- $stringFunctions : array<string|int, mixed>
- Supported standard SQL string functions
- $table : string|null
- Table name
Methods
- __construct() : mixed
- Constructor
- __toString() : string
- Render the table schema to string
- cascade() : Truncate
- Set the CASCADE flag
- db() : AbstractAdapter|null
- Get the current database adapter object (alias method)
- decrementParameterCount() : AbstractSql
- Decrement parameter count
- 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
- getInfo() : array<string|int, mixed>
- Get the table info
- getOpenQuote() : string|null
- Get open quote
- getParameter() : string
- Get parameter placeholder value
- getParameterCount() : int
- Get parameter count
- getPlaceholder() : string|null
- Get the SQL placeholder
- getTable() : string
- Get the table name
- 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
- isSupportedFunctionCall() : bool
- Check if the value is a single, simple call to a standard SQL supported function, e.g. 'COUNT(*)', 'SUM(total)' or 'MAX(users.id)'
- jsonExtract() : JsonExtract
- Create a JSON path extraction expression, usable as a SELECT column value or an orderBy() argument
- quote() : float|int|string
- Quote the value (if it is not a numeric value)
- quoteId() : string
- Quote the identifier
- render() : string
- Render the table schema
- renderToStatements() : array<string|int, mixed>
- Render the table schema to an array of statements
- setIdQuoteType() : AbstractSql
- Set the quote ID type
- setPlaceholder() : AbstractSql
- Set the placeholder
- 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']
$cascade
CASCADE flag
protected
bool
$cascade
= false
$closeQuote
ID close quote
protected
string|null
$closeQuote
= null
$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
$idQuoteType
ID quote type
protected
string
$idQuoteType
= 'NO_QUOTE'
$info
Table info
protected
array<string|int, mixed>
$info
= []
$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
$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']
$table
Table name
protected
string|null
$table
= null
Methods
__construct()
Constructor
public
__construct(string $table, AbstractAdapter $db) : mixed
Instantiate the table object
Parameters
- $table : string
- $db : AbstractAdapter
__toString()
Render the table schema to string
public
__toString() : string
Return values
stringcascade()
Set the CASCADE flag
public
cascade() : Truncate
Return values
Truncatedb()
Get the current database adapter object (alias method)
public
db() : AbstractAdapter|null
Return values
AbstractAdapter|nulldecrementParameterCount()
Decrement parameter count
public
decrementParameterCount() : AbstractSql
Return values
AbstractSqlgetCloseQuote()
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
stringgetInfo()
Get the table info
public
getInfo() : array<string|int, mixed>
Return values
array<string|int, mixed>getOpenQuote()
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|nullgetTable()
Get the table name
public
getTable() : string
Return values
stringincrementParameterCount()
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(mixed $value) : bool
Parameters
- $value : mixed
Return values
boolisSupportedFunctionCall()
Check if the value is a single, simple call to a standard SQL supported function, e.g. 'COUNT(*)', 'SUM(total)' or 'MAX(users.id)'
public
static isSupportedFunctionCall(mixed $value) : bool
The argument list is deliberately restricted to identifier characters, digits, '*', '.', ',' and whitespace, and the whole value must be nothing but that one call. That keeps anything that could carry additional SQL (quotes, operators, comment markers, a nested statement) out of the "render me verbatim" path.
Parameters
- $value : mixed
Return values
booljsonExtract()
Create a JSON path extraction expression, usable as a SELECT column value or an orderBy() argument
public
jsonExtract(string $column, string $path) : JsonExtract
Parameters
- $column : string
- $path : string
Return values
JsonExtractquote()
Quote the value (if it is not a numeric value)
public
quote([mixed $value = null ][, bool $force = false ]) : float|int|string
Parameters
- $value : mixed = null
- $force : bool = false
Return values
float|int|stringquoteId()
Quote the identifier
public
quoteId(string $identifier) : string
A supported SQL function call is an expression rather than an identifier, so it is
passed through untouched - quoting it would produce a bogus identifier such as
COUNT(*), which errors on MySQL/PostgreSQL and silently matches nothing on SQLite.
Parameters
- $identifier : string
Return values
stringrender()
Render the table schema
public
render() : string
SQLite has no TRUNCATE TABLE statement, so DELETE FROM is used instead to achieve the same effect of removing all rows from the table.
Return values
stringrenderToStatements()
Render the table schema to an array of statements
public
renderToStatements() : array<string|int, mixed>
Return values
array<string|int, mixed>setIdQuoteType()
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
AbstractSqlinit()
Initialize SQL object
protected
init(string $adapter) : void
Parameters
- $adapter : string
initQuoteType()
Initialize quite type
protected
initQuoteType() : void