Class Database
Database class provides a layer on top of mysqli
-
mysqli
-
Database
Methods summary
public
|
#
__construct( string|$config $host = 'localhost', string $user = null, string $pass = null, string $db = null, integer $port = null, string $socket = null )
Construct the Database
Since this extends MySQL all the MySQL construct params are kept in tact.
However, you may just supply an object with the following properties if you
prefer: $o->dbUser, $o->dbPass, $o->dbHost, $o->dbName,
$config->dbPort, $config->dbSocket (optional). This would usually be from
a ProcessWire Config ($config) API var, but kept as generic object in case
someone wants to use this class elsewhere.
Parameters
- $host
string|$config Hostname or object with config properties.
- $user
string Username
- $pass
string Password
- $db
string Database name
- $port
integer Port
- $socket
string Socket
|
public
mixed
|
#
query( string $sql, integer $resultmode = MYSQLI_STORE_RESULT )
Overrides default mysqli query method so that it also records and times
queries.
Overrides default mysqli query method so that it also records and times
queries.
Parameters
Returns
mixed Returns FALSE on failure. For successful SELECT, SHOW, DESCRIBE or EXPLAIN
queries mysqli_query() will return a MySQLi_Result object. For other successful
queries mysqli_query() will return TRUE.
|
public static
array
|
#
getQueryLog( )
Get an array of all queries that have been executed thus far
Get an array of all queries that have been executed thus far
Active in ProcessWire debug mode only
Returns
array
|
public
array
|
#
getTables( )
Get array of all tables in this database.
Get array of all tables in this database.
Returns
array
|
public
boolean
|
#
isOperator( string $str )
Is the given string a database comparison operator?
Is the given string a database comparison operator?
Parameters
- $str
string 1-2 character opreator to test
Returns
boolean
|
public
|
#
setThrowExceptions( boolean $throwExceptions = true )
Set whether Exceptions should be thrown on query errors
Set whether Exceptions should be thrown on query errors
Parameters
- $throwExceptions
boolean Default is true
|
Properties summary
protected static
array
|
$queryLog
|
array() |
#
Log of all queries performed in this instance
Log of all queries performed in this instance
|
protected
boolean
|
$throwExceptions
|
true |
#
Should WireDatabaseException be thrown on error?
Should WireDatabaseException be thrown on error?
|