Documentation

Data extends AbstractSql
in package

Data parser class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2023 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
5.3.0

Table of Contents

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'
$closeQuote  : string
ID close quote
$conflictColumns  : array<string|int, mixed>
Conflict columns for UPSERT
$conflictKey  : string
Conflict key for UPSERT
$db  : AbstractAdapter
Database object
$dbType  : int
Database type
$divide  : int
Divide INSERT groups by # (0 creates one big INSERT statement, 1 creates an INSERT statement per row)
$idQuoteType  : string
ID quote type
$openQuote  : string
ID open quote
$parameterCount  : int
Parameter count
$placeholder  : string
SQL placeholder
$sql  : string
SQL string
$table  : string
Database table
__construct()  : mixed
Constructor
__toString()  : string
__toString magic method
db()  : AbstractAdapter
Get the current database adapter object (alias method)
decrementParameterCount()  : static
Decrement parameter count
getCloseQuote()  : string
Get close quote
getDb()  : AbstractAdapter
Get the current database adapter object
getDbType()  : int
Get the current database type
getDivide()  : int
Get the INSERT divide
getIdQuoteType()  : int
Get the quote ID type
getOpenQuote()  : string
Get open quote
getParameter()  : string
Get parameter placeholder value
getParameterCount()  : int
Get parameter count
getPlaceholder()  : string
Get the SQL placeholder
getSql()  : string
Get SQL string
getTable()  : string
Get the database table
incrementParameterCount()  : static
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
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
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()  : string
Quote the value (if it is not a numeric value)
quoteId()  : string
Quote the identifier
serialize()  : string
Serialize the data into INSERT statements
setDivide()  : Data
Set the INSERT divide
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'

DOUBLE_QUOTE

public mixed DOUBLE_QUOTE = 'DOUBLE_QUOTE'

MYSQL

Constants for database types

public mixed MYSQL = 'MYSQL'

Properties

$closeQuote

ID close quote

protected string $closeQuote = null

$conflictColumns

Conflict columns for UPSERT

protected array<string|int, mixed> $conflictColumns = []

$conflictKey

Conflict key for UPSERT

protected string $conflictKey = null

$divide

Divide INSERT groups by # (0 creates one big INSERT statement, 1 creates an INSERT statement per row)

protected int $divide = 1

$idQuoteType

ID quote type

protected string $idQuoteType = 'NO_QUOTE'

$openQuote

ID open quote

protected string $openQuote = null

$parameterCount

Parameter count

protected int $parameterCount = 0

$placeholder

SQL placeholder

protected string $placeholder = null

$sql

SQL string

protected string $sql = null

$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
Return values
mixed

__toString()

__toString magic method

public __toString() : string
Return values
string

decrementParameterCount()

Decrement parameter count

public decrementParameterCount() : static
Return values
static

getCloseQuote()

Get close quote

public getCloseQuote() : string
Return values
string

getDbType()

Get the current database type

public getDbType() : int
Return values
int

getDivide()

Get the INSERT divide

public getDivide() : int
Return values
int

getIdQuoteType()

Get the quote ID type

public getIdQuoteType() : int
Return values
int

getOpenQuote()

Get open quote

public getOpenQuote() : string
Return values
string

getParameter()

Get parameter placeholder value

public getParameter(mixed $value[, string $column = null ]) : string
Parameters
$value : mixed
$column : string = null
Return values
string

getParameterCount()

Get parameter count

public getParameterCount() : int
Return values
int

getPlaceholder()

Get the SQL placeholder

public getPlaceholder() : string
Return values
string

getSql()

Get SQL string

public getSql() : string
Return values
string

getTable()

Get the database table

public getTable() : string
Return values
string

incrementParameterCount()

Increment parameter count

public incrementParameterCount() : static
Return values
static

isMysql()

Determine if the DB type is MySQL

public isMysql() : bool
Return values
bool

isParameter()

Check if value is parameter placeholder

public isParameter(mixed $value[, string $column = null ]) : bool
Parameters
$value : mixed
$column : string = null
Return values
bool

isPgsql()

Determine if the DB type is PostgreSQL

public isPgsql() : bool
Return values
bool

isSerialized()

Check if data was serialized into SQL

public isSerialized() : bool
Return values
bool

isSqlite()

Determine if the DB type is SQLite

public isSqlite() : bool
Return values
bool

isSqlsrv()

Determine if the DB type is SQL Server

public isSqlsrv() : bool
Return values
bool

onConflict()

Set what to do on a insert conflict (UPSERT - PostgreSQL & SQLite)

public onConflict(array<string|int, mixed> $columns[, string $key = null ]) : Data
Parameters
$columns : array<string|int, mixed>
$key : string = null
Return values
Data

onDuplicateKeyUpdate()

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
Data

quote()

Quote the value (if it is not a numeric value)

public quote(string $value[, bool $force = false ]) : string
Parameters
$value : string
$force : bool = false
Return values
string

quoteId()

Quote the identifier

public quoteId(string $identifier) : string
Parameters
$identifier : string
Return values
string

serialize()

Serialize the data into INSERT statements

public serialize(array<string|int, mixed> $data[, mixed $omit = null ][, bool $nullEmpty = false ][, bool $forceQuote = false ]) : string
Parameters
$data : array<string|int, mixed>
$omit : mixed = null
$nullEmpty : bool = false
$forceQuote : bool = false
Return values
string

setDivide()

Set the INSERT divide

public setDivide(int $divide) : Data
Parameters
$divide : int
Return values
Data

setIdQuoteType()

Set the quote ID type

public setIdQuoteType([string $type = self::NO_QUOTE ]) : AbstractSql
Parameters
$type : string = self::NO_QUOTE
Return values
AbstractSql

setTable()

Set the database table

public setTable(string $table) : Data
Parameters
$table : string
Return values
Data

streamToFile()

Serialize the data into INSERT statements

public streamToFile(array<string|int, mixed> $data, string $to[, mixed $omit = null ][, bool $nullEmpty = false ][, string $header = null ][, string $footer = null ]) : void
Parameters
$data : array<string|int, mixed>
$to : string
$omit : mixed = null
$nullEmpty : bool = false
$header : string = null
$footer : string = null
Return values
void

writeToFile()

Output SQL to a file

public writeToFile(string $to[, string $header = null ][, string $footer = null ]) : void
Parameters
$to : string
$header : string = null
$footer : string = null
Return values
void

formatConflicts()

Method to format conflicts (UPSERT)

protected formatConflicts() : string
Return values
string

init()

Initialize SQL object

protected init(string $adapter) : void
Parameters
$adapter : string
Return values
void

initQuoteType()

Initialize quite type

protected initQuoteType() : void
Return values
void

Search results