Core_DataBase
in package
Abstract DataBase
Tags
Table of Contents
- $instance : mixed
- The singleton instances.
- $_asObject : mixed
- Get result as object
- $_collations : null|array<string|int, mixed>
- Cache for getCollations()
- $_colors : mixed
- Colors array
- $_columnQuoteCharacter : mixed
- $_config : mixed
- Driver's configuration
- $_connection : mixed
- Driver's connection
- $_engines : null|array<string|int, mixed>
- Cache for getEngines()
- $_lastQuery : mixed
- Last executed query
- $_likeReplacements : array<string|int, mixed>
- Array of replacements for LIKE
- $_queryType : mixed
- Type of query: 0 - SELECT 1 - INSERT 2 - UPDATE 3 - DELETE 4 - RENAME 5 - ALTER 6 - DROP 7 - TRUNCATE 8 - OPTIMIZE 9 - SHOW 10 - LOCK 99 - OTHER
- $_separator : mixed
- Array of allowed separators, e.g. table.field => `table`.`field`, a + b => `a` + `b`
- $_tableQuoteCharacter : mixed
- $_unbuffered : mixed
- Query without fetching and buffering the result rows
- $_words : mixed
- Words array
- __construct() : mixed
- Constructor.
- __destruct() : mixed
- Destructor
- asAssoc() : self
- Set result type as an array
- asObject() : self
- Set result type as an object with className
- begin() : self
- Start SQL-transaction
- commit() : self
- Commit SQL-transaction
- connect() : bool
- Connect to the database
- current() : mixed
- Get next row for last query result as an associative array or as an object
- disconnect() : self
- Close connection
- dump() : mixed
- Create table $tableName dump
- escape() : string
- Escapes special characters in a string for use in an SQL statement
- escapeLike() : string
- Escape value in LIKE conditions
- free() : self
- Free last result memory
- getAffectedRows() : int|null
- Get number of affected rows in previous MySQL operation
- getCollations() : array<string|int, mixed>
- Get Collations
- getColumnCount() : int|null
- Returns the number of columns in the result set
- getColumns() : array<string|int, mixed>
- Get list of columns in the table
- getColumnType() : array<string|int, mixed>
- Get database colimn type
- getColumnTypeAndLength() : array<string|int, mixed>
- Split column type into type and length
- getConfig() : array<string|int, mixed>
- Get current config array (without username and password)
- getEngines() : array<string|int, mixed>
- Get engines
- getFullColumns() : array<string|int, mixed>
- Get list of columns in the table
- getIndexes() : array<string|int, mixed>
- Get list of indexes in the table
- getInsertId() : int|null
- Get the ID generated in the last query
- getLastQuery() : string
- Get last query
- getProcesslist() : array<string|int, mixed>
- Get the process list indicates the operations currently being performed
- getQueryType() : int
- Get type of query
- getResult() : resource
- Get last query result as resource
- getTables() : array<string|int, mixed>
- Get list of tables in the database
- getTablesSchema() : array<string|int, mixed>
- Get tables schema in the database
- getVersion() : string|null
- Get database version
- highlightSql() : string
- Highlight SQL
- instance() : object
- Register an existing instance as a singleton.
- query() : self
- Send a MySQL query
- quote() : string
- Convert and escape value for SQL query.
- quoteColumnName() : string
- Quote column name, e.g. `columnName` for 'columnName', `columnName` AS `columnNameAlias` for array('columnName', 'columnNameAlias')
- quoteTableName() : string
- Quote table name, e.g. `tableName` for 'tableName', `tableName` AS `tableNameAlias` for array('tableName', 'tableNameAlias')
- result() : array<string|int, mixed>
- Get last query result rows as an array of associative arrays or as an array of objects
- rollback() : self
- Rollback SQL-transaction
- setCharset() : self
- Set the client character set
- setConfig() : self
- Set database config
- setQueryType() : self
- Set type of query
- unbuffered() : self
- Query without fetching and buffering the result rows
- _fetch() : array<string|int, mixed>
- Fetch query result
- _getDriverName() : srting
- Get full driver name
Properties
$instance
The singleton instances.
public
static mixed
$instance
= array()
$_asObject
Get result as object
protected
mixed
$_asObject
= \FALSE
$_collations
Cache for getCollations()
protected
null|array<string|int, mixed>
$_collations
= \NULL
$_colors
Colors array
protected
static mixed
$_colors
= array('orange', 'blue', 'green', 'brown')
$_columnQuoteCharacter
protected
mixed
$_columnQuoteCharacter
= '`'
$_config
Driver's configuration
protected
mixed
$_config
= \NULL
$_connection
Driver's connection
protected
mixed
$_connection
= \NULL
$_engines
Cache for getEngines()
protected
null|array<string|int, mixed>
$_engines
= \NULL
$_lastQuery
Last executed query
protected
mixed
$_lastQuery
= \NULL
$_likeReplacements
Array of replacements for LIKE
protected
array<string|int, mixed>
$_likeReplacements
= array('%' => '\\%', '_' => '\\_', '\\' => '\\\\')
$_queryType
Type of query: 0 - SELECT 1 - INSERT 2 - UPDATE 3 - DELETE 4 - RENAME 5 - ALTER 6 - DROP 7 - TRUNCATE 8 - OPTIMIZE 9 - SHOW 10 - LOCK 99 - OTHER
protected
mixed
$_queryType
= \NULL
$_separator
Array of allowed separators, e.g. table.field => `table`.`field`, a + b => `a` + `b`
protected
mixed
$_separator
= array('.', ' + ', ' - ', ' / ', ' * ')
$_tableQuoteCharacter
protected
mixed
$_tableQuoteCharacter
= '`'
$_unbuffered
Query without fetching and buffering the result rows
protected
mixed
$_unbuffered
= \FALSE
$_words
Words array
protected
static mixed
$_words
= array(array('AND', 'IS', '&&', 'LOG', 'NOT', 'NOW', 'MIN', '!', '\\|\\|', 'OR', 'OCT', 'TAN', 'STD', 'SHA', 'ORD', 'XOR', 'ASC', 'DESC'), array('SELECT', 'UPDATE', 'INSERT', 'DELETE', 'USING', 'LIMIT', 'OFFSET', 'SET'), array('DATE', 'INTO', 'FROM', 'THEN', 'WHEN', 'WHERE', 'LEFT JOIN', 'LEFT OUTER JOIN', 'RIGHT JOIN', 'RIGHT OUTER JOIN', 'INNER JOIN', 'JOIN', 'ELSE', 'ORDER BY', 'GROUP BY', 'HAVING', 'ON'), array('ABS', 'ACOS', 'ADDDATE', 'ADDTIME', 'AES_DECRYPT', 'AES_ENCRYPT', '&&', 'ASCII', 'ASIN', 'ATAN2', 'ATAN', 'AVG', 'BETWEEN', 'BIN', 'BINARY', 'BIT_AND', 'BIT_LENGTH', 'BIT_OR', 'BIT_XOR', 'CASE', 'CAST', 'CEIL', 'CEILING', 'CHAR_LENGTH', 'CHAR', 'CHARACTER_LENGTH', 'CHARSET', 'COALESCE', 'COERCIBILITY', 'COLLATION', 'COMPRESS', 'CONCAT_WS', 'CONCAT', 'CONNECTION_ID', 'CONV', 'CONVERT_TZ', 'Convert', 'COS', 'COT', 'COUNT', 'COUNT', 'COUNT(DISTINCT)', 'DISTINCT', 'CRC32', 'CURDATE', 'CURRENT_DATE', 'CURRENT_TIME', 'CURRENT_TIMESTAMP', 'CURRENT_USER', 'CURTIME', 'DATABASE', 'DATE_ADD', 'DATE_FORMAT', 'DATE_SUB', 'DATEDIFF', 'DAY ', 'DAYNAME', 'DAYOFMONTH', 'DAYOFWEEK', 'DAYOFYEAR', 'DECODE', 'DEFAULT', 'DEGREES', 'DES_DECRYPT', 'DES_ENCRYPT', 'DIV', 'ELT', 'ENCODE', 'ENCRYPT', '<=>', 'EXP()', 'EXPORT_SET', 'EXTRACT', 'FIELD', 'FIND_IN_SET', 'FLOOR', 'FORMAT', 'SQL_CALC_FOUND_ROWS ', 'FOUND_ROWS', 'STRAIGHT_JOIN', 'FROM_DAYS', 'FROM_UNIXTIME', 'GET_FORMAT', 'GET_LOCK', 'GREATEST', 'GROUP_CONCAT', 'HEX ', 'HOUR', ' IF ', 'IFNULL', ' IN ', 'INET_ATON', 'INET_NTOA', 'INSTR', 'IS_FREE_LOCK', 'IS NOT NULL', 'IS NOT', 'IS NULL', 'IS_USED_LOCK', 'ISNULL', 'LAST_DAY', 'LAST_INSERT_ID', 'LCASE', 'LEAST', '<<', 'LEFT', 'LENGTH', 'LIKE', 'LN', 'LOAD_FILE', 'LOCALTIME', 'LOCALTIMESTAMP', 'LOCATE', 'LOG10', 'LOG2', 'LOWER', 'LPAD', 'LTRIM', 'MAKE_SET', 'MAKEDATE', 'MAKETIME', 'MASTER_POS_WAIT', 'MATCH', 'MAX', 'MD5', 'MICROSECOND', 'MID', 'MINUTE', 'MOD', '%', 'MONTH', 'MONTHNAME', 'NOT BETWEEN', '!=', 'NOT IN', 'NOT LIKE', 'NOT REGEXP', 'NULLIF', 'OCTET_LENGTH', 'OLD_PASSWORD', 'ORD', 'PASSWORD', 'PERIOD_ADD', 'PERIOD_DIFF', 'PI', '\\+', 'POSITION', 'POW', 'POWER', 'PROCEDURE ANALYSE', 'QUARTER', 'QUOTE', 'RADIANS', 'RAND', 'REGEXP', 'RELEASE_LOCK', 'REPEAT', 'REPLACE', 'REVERSE', '>>', 'RIGHT', 'RLIKE', 'ROUND', 'ROW_COUN', 'RPAD', 'RTRIM', 'SCHEMA', 'SEC_TO_TIME', 'SECOND', 'SESSION_USER', 'SHA1', 'SIGN', 'SLEEP', 'SOUNDEX', 'SOUNDS LIKE', 'SPACE', 'SQRT', 'STDDEV_POP', 'STDDEV_SAMP', 'STDDEV', 'STR_TO_DATE', 'SUBDATE', 'SUBSTR', 'SUBSTRING_INDEX', 'SUBSTRING', 'SUBTIME', 'SUM', 'SYSDATE', 'SYSTEM_USER', 'TIME_FORMAT', 'TIME_TO_SEC', 'TIME', 'TIMEDIFF', '\\*', 'TIMESTAMP', 'TIMESTAMPADD', 'TIMESTAMPDIFF', 'TO_DAYS', 'TRIM', 'TRUNCATE', 'UCASE', 'UNCOMPRESS', 'UNCOMPRESSED_LENGTH', 'UNHEX', 'UNIX_TIMESTAMP', 'UPPER', 'USER', 'UTC_DATE', 'UTC_TIME', 'UTC_TIMESTAMP', 'UUID', 'VALUES', 'VAR_POP', 'VAR_SAMP', 'VARIANCE', 'VERSION', 'WEEK', 'WEEKDAY', 'WEEKOFYEAR', 'YEAR', 'YEARWEE'))
Methods
__construct()
Constructor.
public
__construct(array<string|int, mixed> $config) : mixed
Parameters
- $config : array<string|int, mixed>
-
config
Return values
mixed —__destruct()
Destructor
public
__destruct() : mixed
Return values
mixed —asAssoc()
Set result type as an array
public
abstract asAssoc() : self
Return values
self —asObject()
Set result type as an object with className
public
abstract asObject([mixed $className = NULL ]) : self
Parameters
- $className : mixed = NULL
-
Object class name
Return values
self —begin()
Start SQL-transaction
public
abstract begin([string $IsolationLevel = NULL ]) : self
Parameters
- $IsolationLevel : string = NULL
-
Transaction isolation level
Return values
self —commit()
Commit SQL-transaction
public
abstract commit() : self
Return values
self —connect()
Connect to the database
public
abstract connect() : bool
Return values
bool —current()
Get next row for last query result as an associative array or as an object
public
abstract current([bool $bCache = TRUE ]) : mixed
Parameters
- $bCache : bool = TRUE
-
use cache
Tags
Return values
mixed —array or object
disconnect()
Close connection
public
abstract disconnect() : self
Return values
self —dump()
Create table $tableName dump
public
dump(string $tableName, Core_Out $stdOut) : mixed
Parameters
- $tableName : string
- $stdOut : Core_Out
-
return Core_DataBase
Return values
mixed —escape()
Escapes special characters in a string for use in an SQL statement
public
abstract escape(string $unescapedString) : string
Parameters
- $unescapedString : string
-
The string that is to be escaped
Return values
string —Escaped string
escapeLike()
Escape value in LIKE conditions
public
escapeLike(string $value) : string
Parameters
- $value : string
Return values
string —free()
Free last result memory
public
abstract free() : self
Return values
self —getAffectedRows()
Get number of affected rows in previous MySQL operation
public
abstract getAffectedRows() : int|null
Return values
int|null —number of affected rows or NULL
getCollations()
Get Collations
public
getCollations() : array<string|int, mixed>
Return values
array<string|int, mixed> —array[Charset] => array of collations
getColumnCount()
Returns the number of columns in the result set
public
abstract getColumnCount() : int|null
Return values
int|null —number of columns in the result set
getColumns()
Get list of columns in the table
public
getColumns(string $tableName[, mixed $selectionCondition = NULL ]) : array<string|int, mixed>
Parameters
- $tableName : string
-
Table name
- $selectionCondition : mixed = NULL
-
Selection condition
Tags
Return values
array<string|int, mixed> —getColumnType()
Get database colimn type
public
getColumnType(string $columnType) : array<string|int, mixed>
Parameters
- $columnType : string
Return values
array<string|int, mixed> —getColumnTypeAndLength()
Split column type into type and length
public
getColumnTypeAndLength(string $columnType) : array<string|int, mixed>
Parameters
- $columnType : string
-
column type
Return values
array<string|int, mixed> —0 => type, 1 => length
getConfig()
Get current config array (without username and password)
public
getConfig() : array<string|int, mixed>
Return values
array<string|int, mixed> —getEngines()
Get engines
public
getEngines() : array<string|int, mixed>
Return values
array<string|int, mixed> —getFullColumns()
Get list of columns in the table
public
getFullColumns(string $tableName[, mixed $selectionCondition = NULL ]) : array<string|int, mixed>
Parameters
- $tableName : string
-
Table name
- $selectionCondition : mixed = NULL
-
Selection condition
Return values
array<string|int, mixed> —getIndexes()
Get list of indexes in the table
public
getIndexes(string $tableName[, mixed $selectionCondition = NULL ]) : array<string|int, mixed>
Parameters
- $tableName : string
-
Table name
- $selectionCondition : mixed = NULL
-
Selection condition
Return values
array<string|int, mixed> —getInsertId()
Get the ID generated in the last query
public
abstract getInsertId() : int|null
Return values
int|null —getLastQuery()
Get last query
public
getLastQuery() : string
Return values
string —getProcesslist()
Get the process list indicates the operations currently being performed
public
abstract getProcesslist() : array<string|int, mixed>
Return values
array<string|int, mixed> —getQueryType()
Get type of query
public
getQueryType() : int
Return values
int —getResult()
Get last query result as resource
public
abstract getResult() : resource
Return values
resource —getTables()
Get list of tables in the database
public
abstract getTables([mixed $selectionCondition = NULL ]) : array<string|int, mixed>
Parameters
- $selectionCondition : mixed = NULL
-
Selection condition
Return values
array<string|int, mixed> —getTablesSchema()
Get tables schema in the database
public
abstract getTablesSchema([mixed $selectionCondition = NULL ]) : array<string|int, mixed>
Parameters
- $selectionCondition : mixed = NULL
-
Selection condition
Return values
array<string|int, mixed> —getVersion()
Get database version
public
abstract getVersion() : string|null
Return values
string|null —highlightSql()
Highlight SQL
public
highlightSql(string $sql) : string
Parameters
- $sql : string
-
SQL
Return values
string —SQL
instance()
Register an existing instance as a singleton.
public
static instance([string $name = 'default' ]) : object
Parameters
- $name : string = 'default'
-
driver's name
Return values
object —query()
Send a MySQL query
public
abstract query(string $sql) : self
Parameters
- $sql : string
-
An SQL query. The query string should not end with a semicolon. Data inside the query should be properly escaped.
Return values
self —quote()
Convert and escape value for SQL query.
public
quote(mixed $value) : string
Parameters
- $value : mixed
Return values
string —quoteColumnName()
Quote column name, e.g. `columnName` for 'columnName', `columnName` AS `columnNameAlias` for array('columnName', 'columnNameAlias')
public
abstract quoteColumnName(mixed $columnName) : string
Parameters
- $columnName : mixed
-
string|array
Return values
string —quoteTableName()
Quote table name, e.g. `tableName` for 'tableName', `tableName` AS `tableNameAlias` for array('tableName', 'tableNameAlias')
public
abstract quoteTableName(mixed $tableName) : string
Parameters
- $tableName : mixed
Return values
string —result()
Get last query result rows as an array of associative arrays or as an array of objects
public
abstract result([bool $bCache = TRUE ]) : array<string|int, mixed>
Parameters
- $bCache : bool = TRUE
-
use cache
Tags
Return values
array<string|int, mixed> —rollback()
Rollback SQL-transaction
public
abstract rollback() : self
Return values
self —setCharset()
Set the client character set
public
abstract setCharset(string $charset) : self
Parameters
- $charset : string
-
A valid character set name.
Return values
self —setConfig()
Set database config
public
setConfig(array<string|int, mixed> $config) : self
Parameters
- $config : array<string|int, mixed>
-
config
Return values
self —setQueryType()
Set type of query
public
setQueryType(int $queryType) : self
Parameters
- $queryType : int
Return values
self —unbuffered()
Query without fetching and buffering the result rows
public
unbuffered(bool $unbuffered) : self
Parameters
- $unbuffered : bool
Return values
self —_fetch()
Fetch query result
protected
abstract _fetch( $result[, bool $bCache = TRUE ]) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed> —_getDriverName()
Get full driver name
protected
static _getDriverName(string $driver) : srting
Parameters
- $driver : string
-
driver name