Data
        
        extends AbstractSql
    
    
            
            in package
            
        
    
    
    
Data class to output data to a valid SQL file
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
- $closeQuote : string|null
- ID close quote
- $conflictColumns : array<string|int, mixed>
- Conflict columns for UPSERT
- $conflictKey : string|null
- Conflict key for UPSERT
- $dateTimeFunctions : array<string|int, mixed>
- Supported standard SQL date-time functions
- $db : AbstractAdapter|null
- Database object
- $dbType : string|null
- Database type
- $divide : int
- Divide INSERT groups by # (0 creates one big INSERT statement, 1 creates an INSERT statement per row)
- $forceUpdate : bool
- Force UPDATE instead of UPSERT if conflict keys/columns are provided
- $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
- $sql : string|null
- SQL string
- $stringFunctions : array<string|int, mixed>
- Supported standard SQL string functions
- $table : string
- Database table
Methods
- __construct() : mixed
- Constructor
- __toString() : string
- __toString magic method
- 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
- getDivide() : int
- Get the INSERT divide
- 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
- getSql() : string|null
- Get SQL string
- getTable() : string
- Get the database table
- incrementParameterCount() : AbstractSql
- Increment parameter count
- isForceUpdate() : bool
- Is force update
- 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
- isSerialized() : bool
- Check if data was serialized into SQL
- 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
- onConflict() : Data
- Set what to do on a insert conflict (UPSERT - PostgreSQL & SQLite)
- onDuplicateKeyUpdate() : Data
- Set columns to handle duplicates/conflicts (UPSERT - MySQL-ism)
- quote() : float|int|string
- Quote the value (if it is not a numeric value)
- quoteId() : string
- Quote the identifier
- serialize() : string|null
- Serialize the data into INSERT statements
- setDivide() : Data
- Set the INSERT divide
- setForceUpdate() : Data
- Set force update
- setIdQuoteType() : AbstractSql
- Set the quote ID type
- setPlaceholder() : AbstractSql
- Set the placeholder
- setTable() : Data
- Set the database table
- streamToFile() : void
- Serialize the data into INSERT statements
- writeToFile() : void
- Output SQL to a file
- formatConflicts() : string
- Method to format conflicts (UPSERT)
- 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']
    
    
    
$closeQuote
ID close quote
    protected
        string|null
    $closeQuote
     = null
    
    
    
$conflictColumns
Conflict columns for UPSERT
    protected
        array<string|int, mixed>
    $conflictColumns
     = []
    
    
    
$conflictKey
Conflict key for UPSERT
    protected
        string|null
    $conflictKey
     = 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
    
    
    
$divide
Divide INSERT groups by # (0 creates one big INSERT statement, 1 creates an INSERT statement per row)
    protected
        int
    $divide
     = 1
    
    
    
$forceUpdate
Force UPDATE instead of UPSERT if conflict keys/columns are provided
    protected
        bool
    $forceUpdate
     = false
    
    
    
$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
    
    
    
$sql
SQL string
    protected
        string|null
    $sql
     = 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
Database table
    protected
        string
    $table
     = 'pop_db_data'
    
    
    
Methods
__construct()
Constructor
    public
                    __construct(AbstractAdapter $db[, string $table = 'pop_db_data' ][, int $divide = 1 ]) : mixed
    Instantiate the SQL object
Parameters
- $db : AbstractAdapter
- $table : string = 'pop_db_data'
- $divide : int = 1
__toString()
__toString magic method
    public
                    __toString() : string
    Return values
stringdb()
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|nullgetDivide()
Get the INSERT divide
    public
                    getDivide() : int
    Return values
intgetIdQuoteType()
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|nullgetSql()
Get SQL string
    public
                    getSql() : string|null
    Return values
string|nullgetTable()
Get the database table
    public
                    getTable() : string
    Return values
stringincrementParameterCount()
Increment parameter count
    public
                    incrementParameterCount() : AbstractSql
    Return values
AbstractSqlisForceUpdate()
Is force update
    public
                    isForceUpdate() : bool
    Return values
boolisMysql()
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
boolisSerialized()
Check if data was serialized into SQL
    public
                    isSerialized() : 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
boolonConflict()
Set what to do on a insert conflict (UPSERT - PostgreSQL & SQLite)
    public
                    onConflict(array<string|int, mixed> $columns[, string|null $key = null ]) : Data
    Parameters
- $columns : array<string|int, mixed>
- $key : string|null = null
Return values
DataonDuplicateKeyUpdate()
Set columns to handle duplicates/conflicts (UPSERT - MySQL-ism)
    public
                    onDuplicateKeyUpdate(array<string|int, mixed> $columns) : Data
    Parameters
- $columns : array<string|int, mixed>
Return values
Dataquote()
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
stringserialize()
Serialize the data into INSERT statements
    public
                    serialize(array<string|int, mixed> $data[, mixed $omit = null ][, bool $nullEmpty = false ][, bool $forceQuote = false ]) : string|null
    Parameters
- $data : array<string|int, mixed>
- $omit : mixed = null
- $nullEmpty : bool = false
- $forceQuote : bool = false
Return values
string|nullsetDivide()
Set the INSERT divide
    public
                    setDivide(int $divide) : Data
    Parameters
- $divide : int
Return values
DatasetForceUpdate()
Set force update
    public
                    setForceUpdate([bool $forceUpdate = true ][, string $conflictKey = 'id' ]) : Data
    Parameters
- $forceUpdate : bool = true
- $conflictKey : string = 'id'
Return values
DatasetIdQuoteType()
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
AbstractSqlsetTable()
Set the database table
    public
                    setTable(string $table) : Data
    Parameters
- $table : string
Return values
DatastreamToFile()
Serialize the data into INSERT statements
    public
                    streamToFile(array<string|int, mixed> $data, string|null $to[, mixed $omit = null ][, bool $nullEmpty = false ][, string|null $header = null ][, string|null $footer = null ]) : void
    Parameters
- $data : array<string|int, mixed>
- $to : string|null
- $omit : mixed = null
- $nullEmpty : bool = false
- $header : string|null = null
- $footer : string|null = null
writeToFile()
Output SQL to a file
    public
                    writeToFile(string $to[, string|null $header = null ][, string|null $footer = null ]) : void
    Parameters
- $to : string
- $header : string|null = null
- $footer : string|null = null
formatConflicts()
Method to format conflicts (UPSERT)
    protected
                    formatConflicts() : string
    Return values
stringinit()
Initialize SQL object
    protected
                    init(string $adapter) : void
    Parameters
- $adapter : string
initQuoteType()
Initialize quite type
    protected
                    initQuoteType() : void