KEY
+KEY+
+ +
diff --git a/docs/.htaccess b/docs/.htaccess
new file mode 100644
index 0000000..7b01f9b
--- /dev/null
+++ b/docs/.htaccess
@@ -0,0 +1,5 @@
+# Fixes a vulnerability in CentOS: http://stackoverflow.com/questions/20533279/prevent-php-from-parsing-non-php-files-such-as-somefile-php-txt
+
Name | -Description | -- |
---|---|---|
- Exception - | -- No description available - | -EMPTY - | -
- InvalidArgumentException - | -- No description available - | -EMPTY - | -
- LogicException - | -- No description available - | -EMPTY - | -
- PDO - | -- No description available - | -EMPTY - | -
- PDOStatement - | -- No description available - | -EMPTY - | -
Name | -Description | -- |
---|---|---|
- AbstractDriver - | -Base Database class | -PASSED | -
- AbstractQueryBuilder - | -Abstract Class for internal implementation methods of the Query Builder | -PASSED | -
- AbstractSQL - | -parent for database manipulation subclasses | -PASSED | -
- AbstractUtil - | -Abstract class defining database / table creation methods | -PASSED | -
- BadDBDriverException - | -Generic exception for bad drivers | -EMPTY - | -
- ConnectionManager - | -Connection manager class to manage connections for the Query method | -PASSED | -
- QueryBuilder - | -Convenience class for creating sql queries - also the class that instantiates the specific db driver | -PASSED | -
- QueryParser - | -Utility Class to parse sql clauses for properly escaping identifiers | -PASSED | -
Name | -Description | -- |
---|---|---|
- Driver - | -Firebird Database class | -PASSED | -
- Result - | -Firebird result class to emulate PDOStatement Class - only implements data-fetching methods | -PASSED | -
- SQL - | -Firebird Specific SQL | -PASSED | -
- Util - | -Firebird-specific backup, import and creation methods | -PASSED | -
Name | -Description | -- |
---|---|---|
- Driver - | -MySQL specific class | -UNTESTED | -
- SQL - | -MySQL specifc SQL | -PASSED | -
- Util - | -MySQL-specific backup, import and creation methods | -PASSED | -
function __clone()
-
- public function __toString()
-
- public function getCode()
-
- public function getFile()
-
- public function getLine()
-
- public function getMessage()
-
- public function getPrevious()
-
- public function getTrace()
-
- public function getTraceAsString()
-
- function __clone()
-
- public function __toString()
-
- public function getCode()
-
- public function getFile()
-
- public function getLine()
-
- public function getMessage()
-
- public function getPrevious()
-
- public function getTrace()
-
- public function getTraceAsString()
-
- function __clone()
-
- public function __toString()
-
- public function getCode()
-
- public function getFile()
-
- public function getLine()
-
- public function getMessage()
-
- public function getPrevious()
-
- public function getTrace()
-
- public function getTraceAsString()
-
- public function __construct(string
- $dsn,
- string
- $username,
- string
- $password,
-
- $driver_options )
-
- $dsn
- —
- string$username
- —
- string$password
- —
- string$driver_options
- —
- Turns off autocommit mode. While autocommit mode is turned off, changes made to the database via the PDO object instance are not committed until you end the transaction by calling PDO::commit. Calling PDO::rollBack will roll back all changes to the database and return the connection to autocommit mode.
-public function beginTransaction()
-
- public function commit()
-
- public function errorCode()
-
- public function errorInfo()
-
- PDO::exec executes an SQL statement in a single function call, returning the number of rows affected by the statement.
-public function exec(string
- $statement )
-
- $statement
- —
- stringThis function returns the value of a database connection attribute. To retrieve PDOStatement attributes, refer to PDOStatement::getAttribute.
-public function getAttribute(int
- $attribute )
-
- $attribute
- —
- intpublic function getAvailableDrivers()
-
- public function inTransaction()
-
- Returns the ID of the last inserted row, or the last value from a sequence object, depending on the underlying driver. For example, PDO_PGSQL requires you to specify the name of a sequence object for the name parameter.
-public function lastInsertId(string
- $name )
-
- $name
- —
- stringPrepares an SQL statement to be executed by the PDOStatement::execute method. The SQL statement can contain zero or more named (:name) or question mark (?) parameter markers for which real values will be substituted when the statement is executed. You cannot use both named and question mark parameter markers within the same SQL statement; pick one or the other parameter style. Use these parameters to bind any user-input, do not include the user-input directly in the query.
-PDO::query executes an SQL statement in a single function call, returning the result set (if any) returned by the statement as a PDOStatement object.
-public function query(string
- $statement )
-
- $statement
- —
- stringPDO::quote places quotes around the input string (if required) and escapes special characters within the input string, using a quoting style appropriate to the underlying driver.
-public function quote(string
- $string,
- int
- $parameter_type )
-
- $string
- —
- string$parameter_type
- —
- intRolls back the current transaction, as initiated by PDO::beginTransaction. A PDOException will be thrown if no transaction is active.
-public function rollBack()
-
- Sets an attribute on the database handle. Some of the available generic attributes are listed below; some drivers may make use of additional driver specific attributes. PDO::ATTR_CASE: Force column names to a specific case. PDO::CASE_LOWER: Force column names to lower case. PDO::CASE_NATURAL: Leave column names as returned by the database driver. PDO::CASE_UPPER: Force column names to upper case. PDO::ATTR_ERRMODE: Error reporting. PDO::ERRMODE_SILENT: Just set error codes. PDO::ERRMODE_WARNING: Raise E_WARNING. PDO::ERRMODE_EXCEPTION: Throw exceptions. PDO::ATTR_ORACLE_NULLS (available with all drivers, not just Oracle): Conversion of NULL and empty strings. PDO::NULL_NATURAL: No conversion. PDO::NULL_EMPTY_STRING: Empty string is converted to NULL. PDO::NULL_TO_STRING: NULL is converted to an empty string. PDO::ATTR_STRINGIFY_FETCHES: Convert numeric values to strings when fetching. Requires bool. PDO::ATTR_STATEMENT_CLASS: Set user-supplied statement class derived from PDOStatement. Cannot be used with persistent PDO instances. Requires array(string classname, array(mixed constructor_args)). PDO::ATTR_TIMEOUT: Specifies the timeout duration in seconds. Not all drivers support this option, and it's meaning may differ from driver to driver. For example, sqlite will wait for up to this time value before giving up on obtaining an writable lock, but other drivers may interpret this as a connect or a read timeout interval. Requires int. PDO::ATTR_AUTOCOMMIT (available in OCI, Firebird and MySQL): Whether to autocommit every single statement. PDO::ATTR_EMULATE_PREPARES Enables or disables emulation of prepared statements. Some drivers do not support native prepared statements or have limited support for them. Use this setting to force PDO to either always emulate prepared statements (if TRUE), or to try to use native prepared statements (if FALSE). It will always fall back to emulating the prepared statement if the driver cannot successfully prepare the current query. Requires bool. PDO::MYSQL_ATTR_USE_BUFFERED_QUERY (available in MySQL): Use buffered queries. PDO::ATTR_DEFAULT_FETCH_MODE: Set default fetch mode. Description of modes is available in PDOStatement::fetch documentation.
-PDOStatement::bindColumn arranges to have a particular variable bound to a given column in the result-set from a query. Each call to PDOStatement::fetch or PDOStatement::fetchAll will update all the variables that are bound to columns.
-public function bindColumn(
- $column,
-
- $param,
- int
- $type,
- int
- $maxlen,
-
- $driverdata )
-
- $column
- —
- $param
- —
- $type
- —
- int$maxlen
- —
- int$driverdata
- —
- Binds a PHP variable to a corresponding named or question mark placeholder in the SQL statement that was used to prepare the statement. Unlike PDOStatement::bindValue, the variable is bound as a reference and will only be evaluated at the time that PDOStatement::execute is called.
-public function bindParam(
- $parameter,
-
- $variable,
- int
- $data_type,
- int
- $length,
-
- $driver_options )
-
- $parameter
- —
- $variable
- —
- $data_type
- —
- int$length
- —
- int$driver_options
- —
- PDOStatement::closeCursor frees up the connection to the server so that other SQL statements may be issued, but leaves the statement in a state that enables it to be executed again.
-public function closeCursor()
-
- Use PDOStatement::columnCount to return the number of columns in the result set represented by the PDOStatement object.
-public function columnCount()
-
- Dumps the informations contained by a prepared statement directly on the output. It will provide the SQL query in use, the number of parameters used (Params), the list of parameters, with their name, type (paramtype) as an integer, their key name or position, the value, and the position in the query (if this is supported by the PDO driver, otherwise, it will be -1).
-public function debugDumpParams()
-
- public function errorCode()
-
- public function errorInfo()
-
- Execute the prepared statement. If the prepared statement included parameter markers, you must either: call PDOStatement::bindParam to bind PHP variables to the parameter markers: bound variables pass their value as input and receive the output value, if any, of their associated parameter markers or pass an array of input-only parameter values
-public function fetch(int
- $fetch_style,
- int
- $cursor_orientation,
- int
- $cursor_offset )
-
- $fetch_style
- —
- int$cursor_orientation
- —
- int$cursor_offset
- —
- intpublic function fetchColumn(int
- $column_number )
-
- $column_number
- —
- intGets an attribute of the statement. Currently, no generic attributes exist but only driver specific: PDO::ATTR_CURSOR_NAME (Firebird and ODBC specific): Get the name of cursor for UPDATE ... WHERE CURRENT OF.
-public function getAttribute(int
- $attribute )
-
- $attribute
- —
- intpublic function getColumnMeta(int
- $column )
-
- $column
- —
- intpublic function nextRowset()
-
- PDOStatement::rowCount returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement executed by the corresponding PDOStatement object.
-public function rowCount()
-
- Sets an attribute on the statement. Currently, no generic attributes are set but only driver specific: PDO::ATTR_CURSOR_NAME (Firebird and ODBC specific): Set the name of cursor for UPDATE ... WHERE CURRENT OF.
-public function setFetchMode(int
- $mode )
-
- $mode
- —
- intAbstract Class for internal implementation methods of the Query Builder
+ + + +$db : \Query\Drivers\DriverInterface+
The current database driver
+ + +$parser : \Query\QueryParser+
Query parser class instance
+ + +$util : \Query\Drivers\AbstractUtil+
Alias to driver util class
+ + +$sql : \Query\Drivers\SQLInterface+
Alias to driver sql class
+ + +_mixedSet(array $var, mixed $key, mixed $val = NULL, integer $valType = self::BOTH) : array+
Set values in the class, with either an array or key value pair
+ + +array | +$var | ++ |
mixed | +$key | ++ |
mixed | +$val | ++ |
integer | +$valType | ++ |
_like(string $field, mixed $val, string $pos, string $like = 'LIKE', string $conj = 'AND') : \Query\QueryBuilderInterface+
Simplify 'like' methods
+ + +string | +$field | ++ |
mixed | +$val | ++ |
string | +$pos | ++ |
string | +$like | ++ |
string | +$conj | ++ |
_having(mixed $key, mixed $val = array(), string $conj = 'AND') : \Query\QueryBuilderInterface+
Simplify building having clauses
+ + +mixed | +$key | ++ |
mixed | +$val | ++ |
string | +$conj | ++ |
_whereString(mixed $key, mixed $val = array(), string $defaultConj = 'AND') : \Query\QueryBuilderInterface+
Simplify generating where string
+ + +mixed | +$key | ++ |
mixed | +$val | ++ |
string | +$defaultConj | ++ |
_whereIn(mixed $key, mixed $val = array(), string $in = 'IN', string $conj = 'AND') : \Query\QueryBuilderInterface+
Simplify where_in methods
+ + +mixed | +$key | ++ |
mixed | +$val | ++ |
string | +$in | +
|
+
string | +$conj | +
|
+
_run(string $type, string $table, string $sql = NULL, array|null $vals = NULL, boolean $reset = TRUE) : \PDOStatement+
Executes the compiled query
+ + +string | +$type | ++ |
string | +$table | ++ |
string | +$sql | ++ |
array|null | +$vals | ++ |
boolean | +$reset | ++ |
Generic exception for bad drivers
+ + + +Connection manager class to manage connections for the +Query method
+ + + +$instance : \Query\ConnectionManager+
Class instance variable
+ + +getInstance() : \Query\ConnectionManager+
Return a connection manager instance
+ + + + +getConnection(string|array|object $name = '') : \Query\QueryBuilderInterface
+ Returns the connection specified by the name given
+ + +string|array|object | +$name | ++ |
connect(\stdClass $params) : \Query\QueryBuilderInterface
+ Parse the passed parameters and return a connection
+ + +\stdClass | +$params | ++ |
+ + + +
Base Database class
+Extends PDO to simplify cross-database issues
+ + +$sql : \Query\Drivers\SQLInterface+
Reference to sql class
+ + +$util : \Query\Drivers\AbstractUtil+
Reference to util class
+ + +getSql() : \Query\Drivers\SQLInterface+
Get the SQL class for the current driver
+ + + + +getUtil() : \Query\Drivers\AbstractUtil+
Get the Util class for the current driver
+ + + + +updateBatch(string $table, array|object $data, string $where) : integer|null+
Creates a batch update, and executes it.
+Returns the number of affected rows
+ +string | +$table | ++ |
array|object | +$data | ++ |
string | +$where | ++ |
parent for database manipulation subclasses
+ + + +Abstract class defining database / table creation methods
+ + + +$conn : \Query\Drivers\DriverInterface+
Reference to the current connection object
+ + +__construct(\Query\Drivers\DriverInterface $conn)
+ Save a reference to the connection object for later use
+ + +\Query\Drivers\DriverInterface | +$conn | ++ |
getDriver() : \Query\Drivers\DriverInterface+
Get the driver object for the current connection
+ + + + +createTable(string $name, array $fields, array $constraints = array(), boolean $ifNotExists = TRUE) : string+
Convenience public function to generate sql for creating a db table
+ + +string | +$name | ++ |
array | +$fields | ++ |
array | +$constraints | ++ |
boolean | +$ifNotExists | ++ |
PDO Interface to implement for database drivers
+ + +__construct(string $dsn, string $username = NULL, string $password = NULL, array $driverOptions = array())+
Constructor/Connection method
+ + +string | +$dsn | ++ |
string | +$username | ++ |
string | +$password | ++ |
array | +$driverOptions | ++ |
updateBatch(string $table, array|object $data, string $where) : integer|null+
Creates a batch update, and executes it.
+Returns the number of affected rows
+ +string | +$table | ++ |
array|object | +$data | ++ |
string | +$where | ++ |
getSql() : \Query\Drivers\SQLInterface+
Get the SQL class for the current driver
+ + + + +getUtil() : \Query\Drivers\AbstractUtil+
Get the Util class for the current driver
+ + + + +Firebird Database class
+PDO-firebird isn't stable, so this is a wrapper of the fbird_ public functions.
+ + +$sql : \Query\Drivers\SQLInterface+
Reference to sql class
+ + +$util : \Query\Drivers\AbstractUtil+
Reference to util class
+ + +__construct(string $dbpath, string $user = 'SYSDBA', string $pass = 'masterkey', array $options = array())+
Open the link to the database
+ + +string | +$dbpath | ++ |
string | +$user | ++ |
string | +$pass | ++ |
array | +$options | ++ |
getSql() : \Query\Drivers\SQLInterface+
Get the SQL class for the current driver
+ + + + +getUtil() : \Query\Drivers\AbstractUtil+
Get the Util class for the current driver
+ + + + +prepareExecute(string $sql, array $args) : \Query\Drivers\Firebird\Result+
Prepare and execute a query
+ + +string | +$sql | ++ |
array | +$args | ++ |
updateBatch(string $table, array|object $data, string $where) : integer|null+
Creates a batch update, and executes it.
+Returns the number of affected rows
+ +string | +$table | ++ |
array|object | +$data | ++ |
string | +$where | ++ |
query(string $sql = '') : \Query\Drivers\Firebird\Result
+ Wrapper public function to better match PDO
+ + +string | +$sql | ++ |
prepare(string $query, array $options = array()) : \Query\Drivers\Firebird\Result+
Emulate PDO prepare
+ + +string | +$query | ++ |
array | +$options | ++ |
Firebird result class to emulate PDOStatement Class - only implements +data-fetching methods
+ + + +$db : \Query\Drivers\Firebird\Driver+
Reference to the db drive to de-duplicate error functions
+ + +__construct(resource $link, \Query\Drivers\Firebird\Driver|null $db = NULL)+
Create the object by passing the resource for +the query
+ + +resource | +$link | ++ |
\Query\Drivers\Firebird\Driver|null | +$db | ++ |
bindColumn(mixed $column, mixed $param, integer $type = NULL, mixed $maxlen = NULL, array $driverdata = NULL) : NULL+
Invalidate method for data consistency
+ + +mixed | +$column | +Number or name of the column in the result set |
+
mixed | +$param | +Name of the PHP variable to which the column will be bound |
+
integer | +$type | +Data type of the parameter, specified by the PDO::PARAM_* constants |
+
mixed | +$maxlen | +A hint for pre-allocation |
+
array | +$driverdata | +Optional parameter(s) for the driver |
+
bindParam(mixed $parameter, mixed $variable, integer $dataType = NULL, mixed $maxlen = NULL, array $driverdata = NULL) : NULL+
Invalidate method for data consistency
+ + +mixed | +$parameter | +Parameter identifier. For a prepared statement using named placeholders, this will be a +parameter name of the form :name. For a prepared statement using question mark placeholders, this will be the +1-indexed position of the parameter. |
+
mixed | +$variable | +Name of the PHP variable to bind to the SQL statement parameter. |
+
integer | +$dataType | +Explicit data type for the parameter using the PDO::PARAM_* constants. To return an INOUT +parameter from a stored procedure, use the bitwise OR operator to set the PDO::PARAM_INPUT_OUTPUT bits +for the data_type parameter. |
+
mixed | +$maxlen | ++ |
array | +$driverdata | ++ |
bindValue(mixed $parameter, mixed $variable, integer $dataType = NULL) : NULL+
Invalidate method for data consistency
+ + +mixed | +$parameter | +Parameter identifier. For a prepared statement using named placeholders, this will be a +parameter name of the form :name. For a prepared statement using question mark placeholders, this will be the +1-indexed position of the parameter. |
+
mixed | +$variable | ++ |
integer | +$dataType | +Explicit data type for the parameter using the PDO::PARAM_* constants. |
+
execute(array $boundInputParams = NULL) : \Query\Drivers\Firebird\Result
+ Run a prepared statement query
+ + +array | +$boundInputParams | ++ |
fetch(integer $fetchStyle = \PDO::FETCH_ASSOC, mixed $cursorOrientation = \PDO::FETCH_ORI_NEXT, mixed $cursorOffset = NULL) : mixed+
Emulate PDO fetch public function
+ + +integer | +$fetchStyle | ++ |
mixed | +$cursorOrientation | ++ |
mixed | +$cursorOffset | ++ |
Firebird Specific SQL
+ + + +Firebird-specific backup, import and creation methods
+ + + +$conn : \Query\Drivers\DriverInterface+
Reference to the current connection object
+ + +__construct(\Query\Drivers\DriverInterface $conn)
+ Save a reference to the connection object for later use
+ + +\Query\Drivers\DriverInterface | +$conn | ++ |
getDriver() : \Query\Drivers\DriverInterface+
Get the driver object for the current connection
+ + + + +createTable(string $name, array $fields, array $constraints = array(), boolean $ifNotExists = FALSE) : string+
Convenience public function to generate sql for creating a db table
+ + +string | +$name | ++ |
array | +$fields | ++ |
array | +$constraints | ++ |
boolean | +$ifNotExists | ++ |
MySQL specific class
+Extends PDO to simplify cross-database issues
+ + +$sql : \Query\Drivers\SQLInterface+
Reference to sql class
+ + +$util : \Query\Drivers\AbstractUtil+
Reference to util class
+ + +getSql() : \Query\Drivers\SQLInterface+
Get the SQL class for the current driver
+ + + + +getUtil() : \Query\Drivers\AbstractUtil+
Get the Util class for the current driver
+ + + + +updateBatch(string $table, array|object $data, string $where) : integer|null+
Creates a batch update, and executes it.
+Returns the number of affected rows
+ +string | +$table | ++ |
array|object | +$data | ++ |
string | +$where | ++ |
MySQL specific SQL
+ + + +MySQL-specific backup, import and creation methods
+ + + +$conn : \Query\Drivers\DriverInterface+
Reference to the current connection object
+ + +__construct(\Query\Drivers\DriverInterface $conn)
+ Save a reference to the connection object for later use
+ + +\Query\Drivers\DriverInterface | +$conn | ++ |
getDriver() : \Query\Drivers\DriverInterface+
Get the driver object for the current connection
+ + + + +createTable(string $name, array $fields, array $constraints = array(), boolean $ifNotExists = TRUE) : string+
Convenience public function to generate sql for creating a db table
+ + +string | +$name | ++ |
array | +$fields | ++ |
array | +$constraints | ++ |
boolean | +$ifNotExists | ++ |
Interface describing the PDO class in PHP
+ + +__construct(string $dsn, string $username, string $password, array $options = array())+
Creates a PDO instance representing a connection to a database
+ + +string | +$dsn | ++ |
string | +$username | ++ |
string | +$password | ++ |
array | +$options | ++ |
Interface created from official PHP Documentation
+ + +bindColumn(mixed $column, mixed $param, integer $type, integer $maxlen, mixed $driverdata) : boolean+
Bind a column to a PHP variable
+ + +mixed | +$column | +Number or name of the column in the result set |
+
mixed | +$param | +Name of the PHP variable to which the column will be bound |
+
integer | +$type | +Data type of the parameter, specified by the PDO::PARAM_* constants |
+
integer | +$maxlen | +A hint for pre-allocation |
+
mixed | +$driverdata | +Optional parameter(s) for the driver |
+
bindParam(mixed $parameter, mixed $variable, integer $dataType = \PDO::PARAM_STR, integer $length, mixed $driverOptions) : boolean+
Binds a parameter to the specified variable name
+ + +mixed | +$parameter | +Parameter identifier. For a prepared statement using named placeholders, this will be a +parameter name of the form :name. For a prepared statement using question mark placeholders, this will be the +1-indexed position of the parameter. |
+
mixed | +$variable | +Name of the PHP variable to bind to the SQL statement parameter. |
+
integer | +$dataType | +Explicit data type for the parameter using the PDO::PARAM_* constants. To return an INOUT +parameter from a stored procedure, use the bitwise OR operator to set the PDO::PARAM_INPUT_OUTPUT bits +for the data_type parameter. |
+
integer | +$length | +Length of the data type. To indicate that a parameter is an OUT parameter from a stored procedure, +you must explicitly set the length. |
+
mixed | +$driverOptions | ++ |
bindValue(mixed $parameter, mixed $value, integer $dataType = \PDO::PARAM_STR) : boolean+
Binds a value to a corresponding named or question mark placeholder in the SQL statement that was used to +prepare the statement
+ + +mixed | +$parameter | +Parameter identifier. For a prepared statement using named placeholders, this will be a +parameter name of the form :name. For a prepared statement using question mark placeholders, this will be the +1-indexed position of the parameter. |
+
mixed | +$value | +The value to bind to the parameter |
+
integer | +$dataType | +Explicit data type for the parameter using the PDO::PARAM_* constants. |
+
fetch(integer $how = \PDO::ATTR_DEFAULT_FETCH_MODE, integer $orientation = \PDO::FETCH_ORI_NEXT, integer $offset) : mixed+
Fetches the next row from a result set
+ + +integer | +$how | ++ |
integer | +$orientation | ++ |
integer | +$offset | ++ |
PostgreSQL specific class
+Extends PDO to simplify cross-database issues
+ + +$sql : \Query\Drivers\SQLInterface+
Reference to sql class
+ + +$util : \Query\Drivers\AbstractUtil+
Reference to util class
+ + +getSql() : \Query\Drivers\SQLInterface+
Get the SQL class for the current driver
+ + + + +getUtil() : \Query\Drivers\AbstractUtil+
Get the Util class for the current driver
+ + + + +updateBatch(string $table, array|object $data, string $where) : integer|null+
Creates a batch update, and executes it.
+Returns the number of affected rows
+ +string | +$table | ++ |
array|object | +$data | ++ |
string | +$where | ++ |
PostgreSQL specific SQL
+ + + +Posgres-specific backup, import and creation methods
+ + + +$conn : \Query\Drivers\DriverInterface+
Reference to the current connection object
+ + +__construct(\Query\Drivers\DriverInterface $conn)
+ Save a reference to the connection object for later use
+ + +\Query\Drivers\DriverInterface | +$conn | ++ |
getDriver() : \Query\Drivers\DriverInterface+
Get the driver object for the current connection
+ + + + +createTable(string $name, array $fields, array $constraints = array(), boolean $ifNotExists = TRUE) : string+
Convenience public function to generate sql for creating a db table
+ + +string | +$name | ++ |
array | +$fields | ++ |
array | +$constraints | ++ |
boolean | +$ifNotExists | ++ |
parent for database manipulation subclasses
+ + +SQLite specific class
+Extends PDO to simplify cross-database issues
+ + +$sql : \Query\Drivers\SQLInterface+
Reference to sql class
+ + +$util : \Query\Drivers\AbstractUtil+
Reference to util class
+ + +getSql() : \Query\Drivers\SQLInterface+
Get the SQL class for the current driver
+ + + + +getUtil() : \Query\Drivers\AbstractUtil+
Get the Util class for the current driver
+ + + + +updateBatch(string $table, array|object $data, string $where) : integer|null+
Creates a batch update, and executes it.
+Returns the number of affected rows
+ +string | +$table | ++ |
array|object | +$data | ++ |
string | +$where | ++ |
SQLite Specific SQL
+ + + +SQLite-specific backup, import and creation methods
+ + + +$conn : \Query\Drivers\DriverInterface+
Reference to the current connection object
+ + +__construct(\Query\Drivers\DriverInterface $conn)
+ Save a reference to the connection object for later use
+ + +\Query\Drivers\DriverInterface | +$conn | ++ |
getDriver() : \Query\Drivers\DriverInterface+
Get the driver object for the current connection
+ + + + +createTable(string $name, array $fields, array $constraints = array(), boolean $ifNotExists = TRUE) : string+
Convenience public function to generate sql for creating a db table
+ + +string | +$name | ++ |
array | +$fields | ++ |
array | +$constraints | ++ |
boolean | +$ifNotExists | ++ |
Convenience class for creating sql queries
+ + + +$db : \Query\Drivers\DriverInterface+
The current database driver
+ + +$parser : \Query\QueryParser+
Query parser class instance
+ + +$util : \Query\Drivers\AbstractUtil+
Alias to driver util class
+ + +$sql : \Query\Drivers\SQLInterface+
Alias to driver sql class
+ + +__construct(\Query\Drivers\DriverInterface $db, \Query\QueryParser $parser)+
Constructor
+ + +\Query\Drivers\DriverInterface | +$db | ++ |
\Query\QueryParser | +$parser | ++ |
select(string $fields) : \Query\QueryBuilderInterface
+ Specifies rows to select in a query
+ + +string | +$fields | ++ |
selectMax(string $field, string|boolean $as = FALSE) : \Query\QueryBuilderInterface+
Selects the maximum value of a field from a query
+ + +string | +$field | ++ |
string|boolean | +$as | ++ |
selectMin(string $field, string|boolean $as = FALSE) : \Query\QueryBuilderInterface+
Selects the minimum value of a field from a query
+ + +string | +$field | ++ |
string|boolean | +$as | ++ |
selectAvg(string $field, string|boolean $as = FALSE) : \Query\QueryBuilderInterface+
Selects the average value of a field from a query
+ + +string | +$field | ++ |
string|boolean | +$as | ++ |
selectSum(string $field, string|boolean $as = FALSE) : \Query\QueryBuilderInterface+
Selects the sum of a field from a query
+ + +string | +$field | ++ |
string|boolean | +$as | ++ |
distinct() : \Query\QueryBuilderInterface+
Adds the 'distinct' keyword to a query
+ + + + +explain() : \Query\QueryBuilderInterface+
Tell the database to give you the query plan instead of result set
+ + + + +from(string $tblname) : \Query\QueryBuilderInterface
+ Specify the database table to select from
+ + +string | +$tblname | ++ |
like(string $field, mixed $val, string $pos = 'both') : \Query\QueryBuilderInterface+
Creates a Like clause in the sql statement
+ + +string | +$field | ++ |
mixed | +$val | ++ |
string | +$pos | ++ |
orLike(string $field, mixed $val, string $pos = 'both') : \Query\QueryBuilderInterface+
Generates an OR Like clause
+ + +string | +$field | ++ |
mixed | +$val | ++ |
string | +$pos | ++ |
notLike(string $field, mixed $val, string $pos = 'both') : \Query\QueryBuilderInterface+
Generates a NOT LIKE clause
+ + +string | +$field | ++ |
mixed | +$val | ++ |
string | +$pos | ++ |
orNotLike(string $field, mixed $val, string $pos = 'both') : \Query\QueryBuilderInterface+
Generates a OR NOT LIKE clause
+ + +string | +$field | ++ |
mixed | +$val | ++ |
string | +$pos | ++ |
having(mixed $key, mixed $val = array()) : \Query\QueryBuilderInterface+
Generates a 'Having' clause
+ + +mixed | +$key | ++ |
mixed | +$val | ++ |
orHaving(mixed $key, mixed $val = array()) : \Query\QueryBuilderInterface+
Generates a 'Having' clause prefixed with 'OR'
+ + +mixed | +$key | ++ |
mixed | +$val | ++ |
where(mixed $key, mixed $val = array(), mixed $escape = NULL) : \Query\QueryBuilderInterface+
Specify condition(s) in the where clause of a query +Note: this function works with key / value, or a +passed array with key / value pairs
+ + +mixed | +$key | ++ |
mixed | +$val | ++ |
mixed | +$escape | ++ |
orWhere(string $key, mixed $val = array()) : \Query\QueryBuilderInterface+
Where clause prefixed with "OR"
+ + +string | +$key | ++ |
mixed | +$val | ++ |
whereIn(mixed $field, mixed $val = array()) : \Query\QueryBuilderInterface+
Where clause with 'IN' statement
+ + +mixed | +$field | ++ |
mixed | +$val | ++ |
orWhereIn(string $field, mixed $val = array()) : \Query\QueryBuilderInterface+
Where in statement prefixed with "or"
+ + +string | +$field | ++ |
mixed | +$val | ++ |
whereNotIn(string $field, mixed $val = array()) : \Query\QueryBuilderInterface+
WHERE NOT IN (FOO) clause
+ + +string | +$field | ++ |
mixed | +$val | ++ |
orWhereNotIn(string $field, mixed $val = array()) : \Query\QueryBuilderInterface+
OR WHERE NOT IN (FOO) clause
+ + +string | +$field | ++ |
mixed | +$val | ++ |
set(mixed $key, mixed $val = NULL) : \Query\QueryBuilderInterface+
Sets values for inserts / updates / deletes
+ + +mixed | +$key | ++ |
mixed | +$val | ++ |
join(string $table, string $condition, string $type = '') : \Query\QueryBuilderInterface+
Creates a join phrase in a compiled query
+ + +string | +$table | ++ |
string | +$condition | ++ |
string | +$type | ++ |
groupBy(mixed $field) : \Query\QueryBuilderInterface
+ Group the results by the selected field(s)
+ + +mixed | +$field | ++ |
orderBy(string $field, string $type = "") : \Query\QueryBuilderInterface+
Order the results by the selected field(s)
+ + +string | +$field | ++ |
string | +$type | ++ |
limit(integer $limit, integer|boolean $offset = FALSE) : \Query\QueryBuilderInterface+
Set a limit on the current sql statement
+ + +integer | +$limit | ++ |
integer|boolean | +$offset | ++ |
groupStart() : \Query\QueryBuilderInterface+
Adds a paren to the current query for query grouping
+ + + + +notGroupStart() : \Query\QueryBuilderInterface+
Adds a paren to the current query for query grouping, +prefixed with 'NOT'
+ + + + +orGroupStart() : \Query\QueryBuilderInterface+
Adds a paren to the current query for query grouping, +prefixed with 'OR'
+ + + + +orNotGroupStart() : \Query\QueryBuilderInterface+
Adds a paren to the current query for query grouping, +prefixed with 'OR NOT'
+ + + + +groupEnd() : \Query\QueryBuilderInterface+
Ends a query group
+ + + + +get(string $table = '', integer|boolean $limit = FALSE, integer|boolean $offset = FALSE) : \PDOStatement+
Select and retrieve all records from the current table, and/or +execute current compiled query
+ + +string | +$table | ++ |
integer|boolean | +$limit | ++ |
integer|boolean | +$offset | ++ |
getWhere(string $table, array $where = array(), integer|boolean $limit = FALSE, integer|boolean $offset = FALSE) : \PDOStatement+
Convenience method for get() with a where clause
+ + +string | +$table | ++ |
array | +$where | ++ |
integer|boolean | +$limit | ++ |
integer|boolean | +$offset | ++ |
countAllResults(string $table = '', boolean $reset = TRUE) : integer+
Retrieve the number of results for the generated query - used +in place of the get() method
+ + +string | +$table | ++ |
boolean | +$reset | +
|
+
updateBatch(string $table, array|object $data, string $where) : integer|null+
Creates a batch update, and executes it.
+Returns the number of affected rows
+ +string | +$table | ++ |
array|object | +$data | ++ |
string | +$where | ++ |
_mixedSet(array $var, mixed $key, mixed $val = NULL, integer $valType = self::BOTH) : array+
Set values in the class, with either an array or key value pair
+ + +array | +$var | ++ |
mixed | +$key | ++ |
mixed | +$val | ++ |
integer | +$valType | ++ |
_like(string $field, mixed $val, string $pos, string $like = 'LIKE', string $conj = 'AND') : \Query\QueryBuilderInterface+
Simplify 'like' methods
+ + +string | +$field | ++ |
mixed | +$val | ++ |
string | +$pos | ++ |
string | +$like | ++ |
string | +$conj | ++ |
_having(mixed $key, mixed $val = array(), string $conj = 'AND') : \Query\QueryBuilderInterface+
Simplify building having clauses
+ + +mixed | +$key | ++ |
mixed | +$val | ++ |
string | +$conj | ++ |
_whereString(mixed $key, mixed $val = array(), string $defaultConj = 'AND') : \Query\QueryBuilderInterface+
Simplify generating where string
+ + +mixed | +$key | ++ |
mixed | +$val | ++ |
string | +$defaultConj | ++ |
_whereIn(mixed $key, mixed $val = array(), string $in = 'IN', string $conj = 'AND') : \Query\QueryBuilderInterface+
Simplify where_in methods
+ + +mixed | +$key | ++ |
mixed | +$val | ++ |
string | +$in | +
|
+
string | +$conj | +
|
+
_run(string $type, string $table, string $sql = NULL, array|null $vals = NULL, boolean $reset = TRUE) : \PDOStatement+
Executes the compiled query
+ + +string | +$type | ++ |
string | +$table | ++ |
string | +$sql | ++ |
array|null | +$vals | ++ |
boolean | +$reset | ++ |
Interface defining the Query Builder class
+ + +select(string $fields) : \Query\QueryBuilderInterface
+ Specifies rows to select in a query
+ + +string | +$fields | ++ |
selectMax(string $field, string|boolean $as = FALSE) : \Query\QueryBuilderInterface+
Selects the maximum value of a field from a query
+ + +string | +$field | ++ |
string|boolean | +$as | ++ |
selectMin(string $field, string|boolean $as = FALSE) : \Query\QueryBuilderInterface+
Selects the minimum value of a field from a query
+ + +string | +$field | ++ |
string|boolean | +$as | ++ |
selectAvg(string $field, string|boolean $as = FALSE) : \Query\QueryBuilderInterface+
Selects the average value of a field from a query
+ + +string | +$field | ++ |
string|boolean | +$as | ++ |
selectSum(string $field, string|boolean $as = FALSE) : \Query\QueryBuilderInterface+
Selects the sum of a field from a query
+ + +string | +$field | ++ |
string|boolean | +$as | ++ |
distinct() : \Query\QueryBuilderInterface+
Adds the 'distinct' keyword to a query
+ + + + +explain() : \Query\QueryBuilderInterface+
Shows the query plan for the query
+ + + + +from(string $tblname) : \Query\QueryBuilderInterface
+ Specify the database table to select from
+ + +string | +$tblname | ++ |
like(string $field, mixed $val, string $pos = 'both') : \Query\QueryBuilderInterface+
Creates a Like clause in the sql statement
+ + +string | +$field | ++ |
mixed | +$val | ++ |
string | +$pos | ++ |
orLike(string $field, mixed $val, string $pos = 'both') : \Query\QueryBuilderInterface+
Generates an OR Like clause
+ + +string | +$field | ++ |
mixed | +$val | ++ |
string | +$pos | ++ |
notLike(string $field, mixed $val, string $pos = 'both') : \Query\QueryBuilderInterface+
Generates a NOT LIKE clause
+ + +string | +$field | ++ |
mixed | +$val | ++ |
string | +$pos | ++ |
orNotLike(string $field, mixed $val, string $pos = 'both') : \Query\QueryBuilderInterface+
Generates a OR NOT LIKE clause
+ + +string | +$field | ++ |
mixed | +$val | ++ |
string | +$pos | ++ |
having(mixed $key, mixed $val = array()) : \Query\QueryBuilderInterface+
Generates a 'Having' clause
+ + +mixed | +$key | ++ |
mixed | +$val | ++ |
orHaving(mixed $key, mixed $val = array()) : \Query\QueryBuilderInterface+
Generates a 'Having' clause prefixed with 'OR'
+ + +mixed | +$key | ++ |
mixed | +$val | ++ |
where(mixed $key, mixed $val = array(), boolean $escape = NULL) : \Query\QueryBuilderInterface+
Specify condition(s) in the where clause of a query +Note: this function works with key / value, or a +passed array with key / value pairs
+ + +mixed | +$key | ++ |
mixed | +$val | ++ |
boolean | +$escape | ++ |
orWhere(string $key, mixed $val = array()) : \Query\QueryBuilderInterface+
Where clause prefixed with "OR"
+ + +string | +$key | ++ |
mixed | +$val | ++ |
whereIn(mixed $field, mixed $val = array()) : \Query\QueryBuilderInterface+
Where clause with 'IN' statement
+ + +mixed | +$field | ++ |
mixed | +$val | ++ |
orWhereIn(string $field, mixed $val = array()) : \Query\QueryBuilderInterface+
Where in statement prefixed with "or"
+ + +string | +$field | ++ |
mixed | +$val | ++ |
whereNotIn(string $field, mixed $val = array()) : \Query\QueryBuilderInterface+
WHERE NOT IN (FOO) clause
+ + +string | +$field | ++ |
mixed | +$val | ++ |
orWhereNotIn(string $field, mixed $val = array()) : \Query\QueryBuilderInterface+
OR WHERE NOT IN (FOO) clause
+ + +string | +$field | ++ |
mixed | +$val | ++ |
set(mixed $key, mixed $val = NULL) : \Query\QueryBuilderInterface+
Sets values for inserts / updates / deletes
+ + +mixed | +$key | ++ |
mixed | +$val | ++ |
join(string $table, string $condition, string $type = '') : \Query\QueryBuilderInterface+
Creates a join phrase in a compiled query
+ + +string | +$table | ++ |
string | +$condition | ++ |
string | +$type | ++ |
groupBy(mixed $field) : \Query\QueryBuilderInterface
+ Group the results by the selected field(s)
+ + +mixed | +$field | ++ |
orderBy(string $field, string $type = "") : \Query\QueryBuilderInterface+
Order the results by the selected field(s)
+ + +string | +$field | ++ |
string | +$type | ++ |
limit(integer $limit, integer|boolean $offset = FALSE) : \Query\QueryBuilderInterface+
Set a limit on the current sql statement
+ + +integer | +$limit | ++ |
integer|boolean | +$offset | ++ |
groupStart() : \Query\QueryBuilderInterface+
Adds a paren to the current query for query grouping
+ + + + +notGroupStart() : \Query\QueryBuilderInterface+
Adds a paren to the current query for query grouping, +prefixed with 'NOT'
+ + + + +orGroupStart() : \Query\QueryBuilderInterface+
Adds a paren to the current query for query grouping, +prefixed with 'OR'
+ + + + +orNotGroupStart() : \Query\QueryBuilderInterface+
Adds a paren to the current query for query grouping, +prefixed with 'OR NOT'
+ + + + +groupEnd() : \Query\QueryBuilderInterface+
Ends a query group
+ + + + +get(string $table = '', integer|boolean $limit = FALSE, integer|boolean $offset = FALSE) : \PDOStatement+
Select and retrieve all records from the current table, and/or +execute current compiled query
+ + +string | +$table | ++ |
integer|boolean | +$limit | ++ |
integer|boolean | +$offset | ++ |
getWhere(string $table, array $where = array(), integer|boolean $limit = FALSE, integer|boolean $offset = FALSE) : \PDOStatement+
Convenience method for get() with a where clause
+ + +string | +$table | ++ |
array | +$where | ++ |
integer|boolean | +$limit | ++ |
integer|boolean | +$offset | ++ |
countAllResults(string $table = '', boolean $reset = TRUE) : integer+
Retrieve the number of results for the generated query - used +in place of the get() method
+ + +string | +$table | ++ |
boolean | +$reset | +
|
+
updateBatch(string $table, array|object $data, string $where) : integer|null+
Creates a batch update, and executes it.
+Returns the number of affected rows
+ +string | +$table | ++ |
array|object | +$data | ++ |
string | +$where | ++ |
Utility Class to parse sql clauses for properly escaping identifiers
+ + + +$db : \Query\Drivers\DriverInterface+
DB Driver
+ + +__construct(\Query\Drivers\DriverInterface $db)
+ Constructor/entry point into parser
+ + +\Query\Drivers\DriverInterface | +$db | ++ |
+ + + +
Extends PDO to simplify cross-database issues
-Methods | -100% | -33 / 33 | -
Lines | -100% | -127 / 127 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update docs-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Lots of refactoring -- accessors/mutators instead of direct access, reduce query builder test database connections, and simplify some logic-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Some scrutinizer fixes-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update docs-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix Firebird tests and speed up tests by using one database connection for each query builder datbase test-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize classes to autoload by namespace-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove some useless code, extract an exception into its own class-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix some very minor code quality issues-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove Table Builder classes-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Improve some tests and docblocks-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove some variable setting logic duplication-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Split Query Builder class-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix access of member variable-
public function __call(string
- $name,
- [array
- $args = ] )
-
- $name
- —
- string$args
- —
- arraypublic function __construct(string
- $dsn,
- [string
- $username = NULL,
- [string
- $password = NULL,
- [array
- $driver_options = ]]] )
-
- $dsn
- —
- string$username
- —
- string$password
- —
- string$driver_options
- —
- arrayprotected function _load_sub_classes()
-
- protected function _prefix(string
- $str )
-
- $str
- —
- stringpublic function _quote(mixed
- $str )
-
- $str
- —
- mixedpublic function affected_rows()
-
-
-
- DriverInterface
-
-
public function driver_query(string|array|null
- $query,
- [boolean
- $filtered_index = TRUE] )
-
- $query
- —
- object$filtered_index
- —
- boolean
-
- DriverInterface
-
-
public function get_columns(string
- $table )
-
- $table
- —
- string
-
- DriverInterface
-
-
public function get_dbs()
-
-
-
- DriverInterface
-
-
public function get_fks(string
- $table )
-
- $table
- —
- string
-
- DriverInterface
-
-
public function get_functions()
-
-
-
- DriverInterface
-
-
public function get_indexes(string
- $table )
-
- $table
- —
- string
-
- DriverInterface
-
-
public function get_last_query()
-
- public function get_procedures()
-
-
-
- DriverInterface
-
-
public function get_schemas()
-
- public function get_sequences()
-
-
-
- DriverInterface
-
-
public function get_sql()
-
-
-
- DriverInterface
-
-
public function get_system_tables()
-
-
-
- DriverInterface
-
-
public function get_tables()
-
-
-
- DriverInterface
-
-
public function get_triggers()
-
-
-
- DriverInterface
-
-
public function get_types()
-
-
-
- DriverInterface
-
-
public function get_util()
-
-
-
- DriverInterface
-
-
public function get_views()
-
-
-
- DriverInterface
-
-
public function insert_batch(string
- $table,
- [array
- $data = ] )
-
- $table
- —
- string$data
- —
- array
-
- DriverInterface
-
-
public function num_rows()
-
-
-
- DriverInterface
-
-
public function prefix_table(string
- $table )
-
- $table
- —
- string
-
- DriverInterface
-
-
public function prepare_execute(string
- $sql,
- array
- $params )
-
- $sql
- —
- string$params
- —
- array
-
- DriverInterface
-
-
public function prepare_query(string
- $sql,
- array
- $data )
-
- $sql
- —
- string$data
- —
- array
- InvalidArgumentException
-
-
-
- DriverInterface
-
-
public function quote_ident(mixed
- $ident )
-
- $ident
- —
- mixed
-
- DriverInterface
-
-
public function quote_table(string
- $table )
-
- $table
- —
- string
-
- DriverInterface
-
-
public function set_last_query(string
- $query_string )
-
- $query_string
- —
- stringpublic function set_table_prefix(string
- $prefix )
-
- $prefix
- —
- stringpublic function truncate(string
- $table )
-
- $table
- —
- stringMethods | -100% | -13 / 13 | -
Lines | -100% | -153 / 153 | -
Name | -Value | -
---|---|
KEY | -0 | -
VALUE | -1 | -
BOTH | -2 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Fix borkeed tests-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Re-add some missing tests, and update README-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Lots of refactoring -- accessors/mutators instead of direct access, reduce query builder test database connections, and simplify some logic-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Some scrutinizer fixes-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update docs-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix some issues with multiple array items in where statements-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize classes to autoload by namespace-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix some very minor code quality issues-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix minor issue of where clause disappearing after a number of joins-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Attempting some Quercus compatibility, test-suite runs with simpletest as well as PHPUnit-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Improve some tests and docblocks-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-method shortening-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove some variable setting logic duplication-
protected function _append_map([string
- $conjunction = '',
- [string
- $string = '',
- [string
- $type = '']]] )
-
- $conjunction
- —
- string$string
- —
- string$type
- —
- stringprotected function _append_query(array
- $vals,
- string
- $sql,
- string
- $total_time )
-
- $vals
- —
- array$sql
- —
- string$total_time
- —
- stringprotected function _compile([string
- $type = '',
- [string
- $table = '']] )
-
- $type
- —
- string$table
- —
- stringprotected function _compile_type([string
- $type = '',
- [string
- $table = '']] )
-
- $type
- —
- string$table
- —
- stringprotected function _get_compile(string
- $type,
- string
- $table,
- bool
- $reset )
-
- $type
- —
- string$table
- —
- string$reset
- —
- objectprotected function _having(mixed
- $key,
- [array
- $val = ,
- [string
- $conj = 'AND']] )
-
- $key
- —
- mixed$val
- —
- array$conj
- —
- stringprotected function _like(string
- $field,
- mixed
- $val,
- string
- $pos,
- [string
- $like = 'LIKE',
- [string
- $conj = 'AND']] )
-
- $field
- —
- string$val
- —
- mixed$pos
- —
- string$like
- —
- string$conj
- —
- stringprotected function _mixed_set(array&
- $var,
- mixed
- $key,
- [mixed
- $val = NULL,
- [int
- $val_type = self::BOTH]] )
-
- $var
- —
- array$key
- —
- mixed$val
- —
- mixed$val_type
- —
- intprotected function _run(string
- $type,
- string
- $table,
- [string
- $sql = NULL,
- [array|null
- $vals = NULL]] )
-
- $type
- —
- string$table
- —
- string$sql
- —
- string$vals
- —
- objectprotected function _select(string
- $field,
- [boolean
- $as = FALSE] )
-
- $field
- —
- string$as
- —
- booleanprotected function _where(mixed
- $key,
- [array
- $val = ] )
-
- $key
- —
- mixed$val
- —
- arrayprotected function _where_in(mixed
- $key,
- [array
- $val = ,
- [string
- $in = 'IN',
- [string
- $conj = 'AND']]] )
-
- $key
- —
- mixed$val
- —
- array$in
- —
- string$conj
- —
- stringprotected function _where_string(mixed
- $key,
- [array
- $val = ,
- [string
- $defaultConj = 'AND']] )
-
- $key
- —
- mixed$val
- —
- array$defaultConj
- —
- stringMethods | -100% | -1 / 1 | -
Lines | -100% | -6 / 6 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize classes to autoload by namespace-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move SQL and Util classes to their own namespaces-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Docblock fixes and more dependency injection-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Test improvements-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add insert_batch methods to Firebird and SQLite-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move abstract classes and interfaces to their own respective folders-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Namespaces!-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update docs, composer and README-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Rename interfaces from iFoo to Foo_Interface-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add abstract class for sql classes to have base limit method-
public function limit(string
- $sql,
- int
- $limit,
- [boolean
- $offset = FALSE] )
-
- $sql
- —
- string$limit
- —
- int$offset
- —
- boolean
-
- SQLInterface
-
-
Methods | -100% | -6 / 6 | -
Lines | -100% | -19 / 19 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize classes to autoload by namespace-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove Table Builder classes-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move SQL and Util classes to their own namespaces-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove __call method from util classes-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reduce complexity of create_table method-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix a few spelling mistakes-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove some duplication-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Docblock updates-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Flesh out the table builder a bit, and add some missing driver methods to SQLite-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix a few code quality issues-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Cut down on some duplication, and increase test coverage-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Rename db_util to abstract_util, mark create_table method as deprecated-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add insert_batch methods to Firebird and SQLite-
public function __construct(DriverInterface
- $conn )
-
- $conn
- —
- Query\Driver_Interfacepublic function backup_data()
-
- public function backup_structure()
-
- public function create_table(string
- $name,
- array
- $fields,
- [array
- $constraints = ,
- [boolean
- $if_not_exists = TRUE]] )
-
- $name
- —
- string$fields
- —
- array$constraints
- —
- array$if_not_exists
- —
- booleanpublic function delete_table(string
- $name )
-
- $name
- —
- stringpublic function get_driver()
-
- Methods | -0% | -0 / 0 | -
Lines | -0% | -0 / 0 | -
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize classes to autoload by namespace-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove some useless code, extract an exception into its own class-
Methods | -77.78% | -7 / 9 | -
Lines | -68.57% | -48 / 70 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Lots of refactoring -- accessors/mutators instead of direct access, reduce query builder test database connections, and simplify some logic-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove php 5.4 style array-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add pdo_firebird driver-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update docs-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix Firebird tests and speed up tests by using one database connection for each query builder datbase test-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize classes to autoload by namespace-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove some useless code, extract an exception into its own class-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Attempting some Quercus compatibility, test-suite runs with simpletest as well as PHPUnit-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Allow camelCase method calls, update interfaces with missing methods-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Docblock fixes and more dependency injection-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix some typos and docblocks-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Rename db_util to abstract_util, mark create_table method as deprecated-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add insert_batch methods to Firebird and SQLite-
public function __clone()
-
-
- DomainException
-
- private function __construct()
-
- public function __sleep()
-
-
- DomainException
-
- public function __wakeup()
-
-
- DomainException
-
- public function connect(stdClass
- $params )
-
- $params
- —
- \stdClassprivate function create_dsn(string
- $dbtype,
- stdClass
- $params )
-
- $dbtype
- —
- string$params
- —
- \stdClasspublic function get_connection([string
- $name = ''] )
-
- $name
- —
- string
- InvalidArgumentException
-
- public function get_instance()
-
- public function parse_params(stdClass
- $params )
-
- $params
- —
- \stdClass
- BadDBDriverException
-
- PDO-firebird isn't stable, so this is a wrapper of the fbird_ public functions.
-Methods | -100% | -19 / 19 | -
Lines | -100% | -58 / 58 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Lots of refactoring -- accessors/mutators instead of direct access, reduce query builder test database connections, and simplify some logic-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Some scrutinizer fixes-
- Author: Scrutinizer Auto-Fixer (auto-fixer@scrutinizer-ci.com) / - Commiter: Scrutinizer Auto-Fixer (auto-fixer@scrutinizer-ci.com) -
-Scrutinizer Auto-Fixes - -This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix Firebird tests and speed up tests by using one database connection for each query builder datbase test-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove some variable setting logic duplication-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Split Query Builder class-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-De-duplicate truncate method of drivers-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move SQL and Util classes to their own namespaces-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Allow camelCase method calls, update interfaces with missing methods-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix some typos and docblocks-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Flesh out the table builder a bit, and add some missing driver methods to SQLite-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Deduplicate error methods in Firebird_Result class-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update drivers with missing method-
public function __construct(string
- $dbpath,
- [string
- $user = 'SYSDBA',
- [string
- $pass = 'masterkey',
- [array
- $options = ]]] )
-
- $dbpath
- —
- string$user
- —
- string$pass
- —
- string$options
- —
- array
- PDOException
-
- public function __destruct()
-
- public function beginTransaction()
-
-
-
- DriverInterface
-
-
- PDO
-
- public function commit()
-
-
-
- DriverInterface
-
-
- PDO
-
- public function errorCode()
-
-
-
- DriverInterface
-
-
- PDO
-
- public function errorInfo()
-
-
-
- DriverInterface
-
-
- PDO
-
- public function exec(string
- $sql )
-
- $sql
- —
- string
-
- DriverInterface
-
-
- PDO
-
- public function getAttribute(int
- $attribute )
-
- $attribute
- —
- int
-
- DriverInterface
-
-
- PDO
-
- public function get_service()
-
- public function inTransaction()
-
-
- PDO
-
- public function insert_batch(string
- $table,
- [array
- $data = ] )
-
- $table
- —
- string$data
- —
- array
-
- DriverInterface
-
-
- AbstractDriver
-
- public function lastInsertId([string
- $name = NULL] )
-
- $name
- —
- string
- PDO
-
- public function prepare(string
- $query,
- [array
- $options = ] )
-
- $query
- —
- string$options
- —
- array
- PDOException
-
-
- PDO
-
- public function prepare_execute(string
- $sql,
- array
- $args )
-
- $sql
- —
- string$args
- —
- array
-
- DriverInterface
-
-
- AbstractDriver
-
- public function prepare_query(string
- $sql,
- array
- $params )
-
- $sql
- —
- string$params
- —
- array
-
- DriverInterface
-
-
- AbstractDriver
-
- public function query([string
- $sql = ''] )
-
- $sql
- —
- string
- PDOException
-
-
- PDO
-
- public function quote(string
- $str,
- [int
- $param_type = PDO::PARAM_STR] )
-
- $str
- —
- string$param_type
- —
- int
- PDO
-
- public function rollBack()
-
-
- PDO
-
- public function setAttribute(int
- $attribute,
- mixed
- $value )
-
- $attribute
- —
- int$value
- —
- mixed
-
- DriverInterface
-
-
- PDO
-
- Methods | -100% | -12 / 12 | -
Lines | -100% | -49 / 49 | -
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Lots of refactoring -- accessors/mutators instead of direct access, reduce query builder test database connections, and simplify some logic-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Some scrutinizer fixes-
- Author: Scrutinizer Auto-Fixer (auto-fixer@scrutinizer-ci.com) / - Commiter: Scrutinizer Auto-Fixer (auto-fixer@scrutinizer-ci.com) -
-Scrutinizer Auto-Fixes - -This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update docs-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix Firebird tests and speed up tests by using one database connection for each query builder datbase test-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix some more docblocks-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Docblock fixes and more dependency injection-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Deduplicate error methods in Firebird_Result class-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update drivers with missing method-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Namespaces!-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Improvements for scrutinizer-
- Author: Scrutinizer Auto-Fixer (auto-fixer@scrutinizer-ci.com) / - Commiter: Scrutinizer (auto-fixer@scrutinizer-ci.com) -
-Scrutinizer Auto-Fixes - -This patch was automatically generated as part of the following inspection: -https://scrutinizer-ci.com/g/timw4mail/Query/inspections/89ed2aa4-7aae-45bb-9289-ebb27a60ef13 - -Enabled analysis tools: - - PHP Analyzer-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Better test coverage-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix some docblocks, and update test files to 2014-
public function __construct(resource
- $link,
- [Driver|null
- $db = NULL] )
-
- $link
- —
- resource$db
- —
- objectpublic function bindColumn(mixed
- $column,
- mixed&
- $param,
- [int
- $type = NULL,
- [mixed
- $maxlen = NULL,
- [array
- $driverdata = NULL]]] )
-
- $column
- —
- mixed$param
- —
- mixed$type
- —
- int$maxlen
- —
- mixed$driverdata
- —
- array
- PDOStatement
-
- public function bindParam(mixed
- $parameter,
- mixed&
- $variable,
- [int
- $data_type = NULL,
- [mixed
- $maxlen = NULL,
- [array
- $driverdata = NULL]]] )
-
- $parameter
- —
- mixed$variable
- —
- mixed$data_type
- —
- int$maxlen
- —
- mixed$driverdata
- —
- array
- PDOStatement
-
- public function bindValue(mixed
- $parameter,
- mixed
- $variable,
- [int
- $data_type = NULL] )
-
- $parameter
- —
- mixed$variable
- —
- mixed$data_type
- —
- int
- PDOStatement
-
- public function errorCode()
-
-
- PDOStatement
-
- public function errorInfo()
-
-
- PDOStatement
-
- public function execute([array
- $args = NULL] )
-
- $args
- —
- array
- PDOStatement
-
- public function fetch([int
- $fetch_style = PDO::FETCH_ASSOC,
- [mixed
- $cursor_orientation = PDO::FETCH_ORI_NEXT,
- [mixed
- $cursor_offset = NULL]]] )
-
- $fetch_style
- —
- int$cursor_orientation
- —
- mixed$cursor_offset
- —
- mixed
- PDOStatement
-
- public function fetchAll([int
- $fetch_style = PDO::FETCH_ASSOC,
- [mixed
- $statement = NULL,
- [mixed
- $ctor_args = NULL]]] )
-
- $fetch_style
- —
- int$statement
- —
- mixed$ctor_args
- —
- mixed
- PDOStatement
-
- public function fetchColumn([integer
- $column_num = 0] )
-
- $column_num
- —
- integer
- PDOStatement
-
- public function fetchObject([string
- $class_name = 'stdClass',
- [array
- $ctor_args = ]] )
-
- $class_name
- —
- string$ctor_args
- —
- array
- PDOStatement
-
- public function rowCount()
-
-
- PDOStatement
-
- Methods | -100% | -15 / 15 | -
Lines | -100% | -26 / 26 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Improve some tests and docblocks-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move SQL and Util classes to their own namespaces-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Docblock fixes and more dependency injection-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add update and delete rules to foreign key methods-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update foreign key driver methods to return the same kind of information-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Flesh out the table builder a bit, and add some missing driver methods to SQLite-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update drivers with missing method-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add method to retrieve foreign keys for a table to driver classes-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Namespaces!-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add abstract class for sql classes to have base limit method-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-More firebird coverage-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add `explain` method to query builder-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update copyright for the new year-
public function column_list(string
- $table )
-
- $table
- —
- string
-
- SQLInterface
-
-
public function db_list()
-
-
-
- SQLInterface
-
-
public function explain(string
- $sql )
-
- $sql
- —
- string
-
- SQLInterface
-
-
public function fk_list(string
- $table )
-
- $table
- —
- string
-
- SQLInterface
-
-
public function function_list()
-
-
-
- SQLInterface
-
-
public function index_list(string
- $table )
-
- $table
- —
- string
-
- SQLInterface
-
-
public function limit(string
- $sql,
- int
- $limit,
- [boolean
- $offset = FALSE] )
-
- $sql
- —
- string$limit
- —
- int$offset
- —
- boolean
-
- SQLInterface
-
-
- AbstractSQL
-
- public function procedure_list()
-
-
-
- SQLInterface
-
-
public function random()
-
-
-
- SQLInterface
-
-
public function sequence_list()
-
-
-
- SQLInterface
-
-
public function system_table_list()
-
-
-
- SQLInterface
-
-
public function table_list()
-
-
-
- SQLInterface
-
-
public function trigger_list()
-
-
-
- SQLInterface
-
-
public function type_list()
-
-
-
- SQLInterface
-
-
public function view_list()
-
-
-
- SQLInterface
-
-
Methods | -75% | -3 / 4 | -
Lines | -94.12% | -32 / 34 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Lots of refactoring -- accessors/mutators instead of direct access, reduce query builder test database connections, and simplify some logic-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix Firebird tests and speed up tests by using one database connection for each query builder datbase test-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move SQL and Util classes to their own namespaces-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove __call method from util classes-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix a few spelling mistakes-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove some duplication-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Docblock fixes and more dependency injection-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Flesh out the table builder a bit, and add some missing driver methods to SQLite-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Deduplicate error methods in Firebird_Result class-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix a few code quality issues-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update drivers with missing method-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Cut down on some duplication, and increase test coverage-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Rename db_util to abstract_util, mark create_table method as deprecated-
public function backup_data([array
- $exclude = ,
- [boolean
- $system_tables = FALSE]] )
-
- $exclude
- —
- array$system_tables
- —
- boolean
- AbstractUtil
-
- public function backup_structure()
-
-
- AbstractUtil
-
- public function create_table(string
- $name,
- array
- $fields,
- [array
- $constraints = ,
- [boolean
- $if_not_exists = FALSE]] )
-
- $name
- —
- string$fields
- —
- array$constraints
- —
- array$if_not_exists
- —
- boolean
- AbstractUtil
-
- public function delete_table(string
- $name )
-
- $name
- —
- string
- AbstractUtil
-
- Methods | -100% | -1 / 1 | -
Lines | -0% | -0 / 0 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Lots of refactoring -- accessors/mutators instead of direct access, reduce query builder test database connections, and simplify some logic-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-De-duplicate truncate method of drivers-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix tests, by fixing some issues with auto-prefixing table names-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Namespaces!-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add interface for pdo drivers to enforce the same interface on the Firebird driver-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix dsn issue in tests-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Improve code coverage-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add `explain` method to query builder-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update copyright for the new year-
- Author: Timothy Warren (tim@timshomepage.net) / - Commiter: Timothy Warren (tim@timshomepage.net) -
-Update year-
- Author: Timothy Warren (tim@timshomepage.net) / - Commiter: Timothy Warren (tim@timshomepage.net) -
-Add interfaces-
- Author: Timothy Warren (tim@timshomepage.net) / - Commiter: Timothy Warren (tim@timshomepage.net) -
-Make mysql/postgres drivers compatible with Quercus-
- Author: Timothy Warren (tim@timshomepage.net) / - Commiter: Timothy Warren (tim@timshomepage.net) -
-Add list_types abstract method to db_sql class-
public function __construct(string
- $dsn,
- [string
- $username = null,
- [string
- $password = null,
- [array
- $options = ]]] )
-
- $dsn
- —
- string$username
- —
- string$password
- —
- string$options
- —
- arrayMethods | -100% | -15 / 15 | -
Lines | -100% | -20 / 20 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move SQL and Util classes to their own namespaces-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add update and delete rules to foreign key methods-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update foreign key driver methods to return the same kind of information-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Test improvements-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update drivers with missing method-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add method to retrieve foreign keys for a table to driver classes-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Micro-optimization for MySQL order by rand-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Namespaces!-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add abstract class for sql classes to have base limit method-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Better test coverage-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add `explain` method to query builder-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update copyright for the new year-
- Author: Timothy Warren (tim@timshomepage.net) / - Commiter: Timothy Warren (tim@timshomepage.net) -
-Changed invalid methods to return NULL instead of FALSE, added insert_batch-
public function column_list(string
- $table )
-
- $table
- —
- string
-
- SQLInterface
-
-
public function db_list()
-
-
-
- SQLInterface
-
-
public function explain(string
- $sql )
-
- $sql
- —
- string
-
- SQLInterface
-
-
public function fk_list(string
- $table )
-
- $table
- —
- string
-
- SQLInterface
-
-
public function function_list()
-
-
-
- SQLInterface
-
-
public function index_list(string
- $table )
-
- $table
- —
- string
-
- SQLInterface
-
-
public function limit(string
- $sql,
- int
- $limit,
- [boolean
- $offset = FALSE] )
-
- $sql
- —
- string$limit
- —
- int$offset
- —
- boolean
-
- SQLInterface
-
-
- AbstractSQL
-
- public function procedure_list()
-
-
-
- SQLInterface
-
-
public function random()
-
-
-
- SQLInterface
-
-
public function sequence_list()
-
-
-
- SQLInterface
-
-
public function system_table_list()
-
-
-
- SQLInterface
-
-
public function table_list([string
- $database = ''] )
-
- $database
- —
- string
-
- SQLInterface
-
-
public function trigger_list()
-
-
-
- SQLInterface
-
-
public function type_list()
-
-
-
- SQLInterface
-
-
public function view_list()
-
-
-
- SQLInterface
-
-
Methods | -100% | -2 / 2 | -
Lines | -100% | -39 / 39 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move SQL and Util classes to their own namespaces-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove __call method from util classes-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Test improvements-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Cut down on some duplication, and increase test coverage-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Rename db_util to abstract_util, mark create_table method as deprecated-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Namespaces!-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-improve query builder and connection manager, skip coverage of some soon-to-be-removed methods-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove pointless constructor over-riding-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix more code quality issues-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-More appeasement of scrutinizer-ci-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix some code quality issues-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove some dead code, update docs-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix some docblocks, and update test files to 2014-
public function backup_data([array
- $exclude = ] )
-
- $exclude
- —
- array
- AbstractUtil
-
- public function backup_structure()
-
-
- AbstractUtil
-
- Methods | -100% | -3 / 3 | -
Lines | -100% | -13 / 13 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Lots of refactoring -- accessors/mutators instead of direct access, reduce query builder test database connections, and simplify some logic-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-De-duplicate truncate method of drivers-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add update and delete rules to foreign key methods-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Namespaces!-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add interface for pdo drivers to enforce the same interface on the Firebird driver-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Minor query formatting changes-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix dsn issue in tests-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Improve code coverage-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update copyright for the new year-
- Author: Timothy Warren (tim@timshomepage.net) / - Commiter: Timothy Warren (tim@timshomepage.net) -
-Update year-
- Author: Timothy Warren (tim@timshomepage.net) / - Commiter: Timothy Warren (tim@timshomepage.net) -
-Add interfaces-
- Author: Timothy Warren (tim@timshomepage.net) / - Commiter: Timothy Warren (tim@timshomepage.net) -
-Make mysql/postgres drivers compatible with Quercus-
- Author: Timothy Warren (tim@timshomepage.net) / - Commiter: Timothy Warren (tim@timshomepage.net) -
-Add list_types abstract method to db_sql class-
public function __construct(string
- $dsn,
- [string
- $username = null,
- [string
- $password = null,
- [array
- $options = ]]] )
-
- $dsn
- —
- string$username
- —
- string$password
- —
- string$options
- —
- arraypublic function get_fks(string
- $table )
-
- $table
- —
- string
-
- DriverInterface
-
-
- AbstractDriver
-
- public function get_schemas()
-
-
- AbstractDriver
-
- Methods | -100% | -14 / 14 | -
Lines | -100% | -20 / 20 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Lots of refactoring -- accessors/mutators instead of direct access, reduce query builder test database connections, and simplify some logic-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add pdo_firebird driver-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix naming error in pg driver-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move SQL and Util classes to their own namespaces-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add update and delete rules to foreign key methods-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update foreign key driver methods to return the same kind of information-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update drivers with missing method-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add method to retrieve foreign keys for a table to driver classes-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Namespaces!-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add abstract class for sql classes to have base limit method-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add `explain` method to query builder-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update copyright for the new year-
- Author: Timothy Warren (tim@timshomepage.net) / - Commiter: Timothy Warren (tim@timshomepage.net) -
-Changed invalid methods to return NULL instead of FALSE, added insert_batch-
public function column_list(string
- $table )
-
- $table
- —
- string
-
- SQLInterface
-
-
public function db_list()
-
-
-
- SQLInterface
-
-
public function explain(string
- $sql )
-
- $sql
- —
- string
-
- SQLInterface
-
-
public function fk_list(string
- $table )
-
- $table
- —
- string
-
- SQLInterface
-
-
public function function_list()
-
-
-
- SQLInterface
-
-
public function index_list(string
- $table )
-
- $table
- —
- string
-
- SQLInterface
-
-
public function procedure_list()
-
-
-
- SQLInterface
-
-
public function random()
-
-
-
- SQLInterface
-
-
public function sequence_list()
-
-
-
- SQLInterface
-
-
public function system_table_list()
-
-
-
- SQLInterface
-
-
public function table_list()
-
-
-
- SQLInterface
-
-
public function trigger_list()
-
-
-
- SQLInterface
-
-
public function type_list()
-
-
-
- SQLInterface
-
-
public function view_list()
-
-
-
- SQLInterface
-
-
Methods | -100% | -2 / 2 | -
Lines | -100% | -27 / 27 | -
Line | -Task | -
---|---|
33 | -Implement Backup function | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move SQL and Util classes to their own namespaces-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove __call method from util classes-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Rename db_util to abstract_util, mark create_table method as deprecated-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Namespaces!-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove redundant method-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Improvements for scrutinizer-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove pointless constructor over-riding-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update some docblocks for __called methods-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix some docblocks, and update test files to 2014-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update copyright for the new year-
- Author: Timothy Warren (tim@timshomepage.net) / - Commiter: Timothy Warren (tim@timshomepage.net) -
-Update year-
- Author: Timothy Warren (tim@timshomepage.net) / - Commiter: Timothy Warren (tim@timshomepage.net) -
-Add list_types abstract method to db_sql class-
- Author: Timothy Warren (tim@timshomepage.net) / - Commiter: Timothy Warren (tim@timshomepage.net) -
-Add package docblock options-
public function backup_data([array
- $exclude = ] )
-
- $exclude
- —
- array
- AbstractUtil
-
- public function backup_structure()
-
-
- AbstractUtil
-
- Line | -Task | -
---|---|
33 | -Implement Backup function | -
Methods | -100% | -4 / 4 | -
Lines | -100% | -17 / 17 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add pdo_firebird driver-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Improve some tests and docblocks-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-De-duplicate truncate method of drivers-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add update and delete rules to foreign key methods-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update foreign key driver methods to return the same kind of information-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Flesh out the table builder a bit, and add some missing driver methods to SQLite-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Cut down on some duplication, and increase test coverage-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Rename db_util to abstract_util, mark create_table method as deprecated-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add insert_batch methods to Firebird and SQLite-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Namespaces!-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add interface for pdo drivers to enforce the same interface on the Firebird driver-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix some code quality issues-
- Author: Scrutinizer Auto-Fixer (auto-fixer@scrutinizer-ci.com) / - Commiter: Scrutinizer (auto-fixer@scrutinizer-ci.com) -
-Scrutinizer Auto-Fixes - -This patch was automatically generated as part of the following inspection: -https://scrutinizer-ci.com/g/timw4mail/Query/inspections/89ed2aa4-7aae-45bb-9289-ebb27a60ef13 - -Enabled analysis tools: - - PHP Analyzer-
public function __construct(string
- $dsn,
- [string
- $user = NULL,
- [string
- $pass = NULL,
- [array
- $driver_options = ]]] )
-
- $dsn
- —
- string$user
- —
- string$pass
- —
- string$driver_options
- —
- arraypublic function get_fks(string
- $table )
-
- $table
- —
- string
-
- DriverInterface
-
-
- AbstractDriver
-
- public function get_tables()
-
-
-
- DriverInterface
-
-
- AbstractDriver
-
- public function insert_batch(string
- $table,
- [array
- $data = ] )
-
- $table
- —
- string$data
- —
- array
-
- DriverInterface
-
-
- AbstractDriver
-
- Methods | -100% | -14 / 14 | -
Lines | -100% | -14 / 14 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Scrutinizer Auto-Fixer (auto-fixer@scrutinizer-ci.com) / - Commiter: Scrutinizer (auto-fixer@scrutinizer-ci.com) -
-Scrutinizer Auto-Fixes - -This patch was automatically generated as part of the following inspection: -https://scrutinizer-ci.com/g/timw4mail/Query/inspections/d131279f-a838-49e5-bbfb-20c256a06153 - -Enabled analysis tools: - - PHP Analyzer-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move SQL and Util classes to their own namespaces-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix some more docblocks-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Flesh out the table builder a bit, and add some missing driver methods to SQLite-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix sql test errors-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update drivers with missing method-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add method to retrieve foreign keys for a table to driver classes-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Namespaces!-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add abstract class for sql classes to have base limit method-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Make sqlite limit statement more different than mysql limit statement-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add interface for pdo drivers to enforce the same interface on the Firebird driver-
- Author: Scrutinizer Auto-Fixer (auto-fixer@scrutinizer-ci.com) / - Commiter: Scrutinizer (auto-fixer@scrutinizer-ci.com) -
-Scrutinizer Auto-Fixes - -This patch was automatically generated as part of the following inspection: -https://scrutinizer-ci.com/g/timw4mail/Query/inspections/89ed2aa4-7aae-45bb-9289-ebb27a60ef13 - -Enabled analysis tools: - - PHP Analyzer-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add `explain` method to query builder-
public function column_list(string
- $table )
-
- $table
- —
- string
-
- SQLInterface
-
-
public function db_list()
-
-
-
- SQLInterface
-
-
public function explain(string
- $sql )
-
- $sql
- —
- string
-
- SQLInterface
-
-
public function fk_list(string
- $table )
-
- $table
- —
- string
-
- SQLInterface
-
-
public function function_list()
-
-
-
- SQLInterface
-
-
public function index_list(string
- $table )
-
- $table
- —
- string
-
- SQLInterface
-
-
public function procedure_list()
-
-
-
- SQLInterface
-
-
public function random()
-
-
-
- SQLInterface
-
-
public function sequence_list()
-
-
-
- SQLInterface
-
-
public function system_table_list()
-
-
-
- SQLInterface
-
-
public function table_list()
-
-
-
- SQLInterface
-
-
public function trigger_list()
-
-
-
- SQLInterface
-
-
public function type_list()
-
-
-
- SQLInterface
-
-
public function view_list()
-
-
-
- SQLInterface
-
-
Methods | -100% | -2 / 2 | -
Lines | -100% | -38 / 38 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Change test setup to be more extensible-
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move SQL and Util classes to their own namespaces-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove __call method from util classes-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix sqlite tests-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Cut down on some duplication, and increase test coverage-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Rename db_util to abstract_util, mark create_table method as deprecated-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Namespaces!-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-improve query builder and connection manager, skip coverage of some soon-to-be-removed methods-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove pointless constructor over-riding-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update some docblocks for __called methods-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-No more skipped tests, and minor update to query formatting-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix some docblocks, and update test files to 2014-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize sqlite tests and improve coverage-
public function backup_data([array
- $excluded = ] )
-
- $excluded
- —
- array
- AbstractUtil
-
- public function backup_structure()
-
-
- AbstractUtil
-
- Methods | -100% | -45 / 45 | -
Lines | -100% | -148 / 148 | -
Name | -Value | -
---|---|
KEY | -0 | -
VALUE | -1 | -
BOTH | -2 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Actually fix tests-
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Set up jenkins build-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update docs-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix some issues with multiple array items in where statements-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize classes to autoload by namespace-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix small docblock discrepency-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add an additional type check to limit-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Attempting some Quercus compatibility, test-suite runs with simpletest as well as PHPUnit-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Improve some tests and docblocks-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-method shortening-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Remove some variable setting logic duplication-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Split Query Builder class-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Allow camelCase method calls, update interfaces with missing methods-
public function __call(string
- $name,
- array
- $params )
-
- $name
- —
- string$params
- —
- array
- BadMethodCallException
-
- public function __construct(DriverInterface
- $db,
- QueryParser
- $parser )
-
- $db
- —
- Query\DriverInterface$parser
- —
- Query\QueryParserpublic function __destruct()
-
- public function count_all(string
- $table )
-
- $table
- —
- string
-
- QueryBuilderInterface
-
-
public function count_all_results([string
- $table = ''] )
-
- $table
- —
- string
-
- QueryBuilderInterface
-
-
public function delete(string
- $table,
- [string
- $where = ''] )
-
- $table
- —
- string$where
- —
- string
-
- QueryBuilderInterface
-
-
public function distinct()
-
-
-
- QueryBuilderInterface
-
-
public function explain()
-
-
-
- QueryBuilderInterface
-
-
public function from(string
- $tblname )
-
- $tblname
- —
- string
-
- QueryBuilderInterface
-
-
public function get([string
- $table = '',
- [boolean
- $limit = FALSE,
- [boolean
- $offset = FALSE]]] )
-
- $table
- —
- string$limit
- —
- boolean$offset
- —
- boolean
-
- QueryBuilderInterface
-
-
public function get_compiled_delete([string
- $table = "",
- [boolean
- $reset = TRUE]] )
-
- $table
- —
- string$reset
- —
- boolean
-
- QueryBuilderInterface
-
-
public function get_compiled_insert(string
- $table,
- [boolean
- $reset = TRUE] )
-
- $table
- —
- string$reset
- —
- boolean
-
- QueryBuilderInterface
-
-
public function get_compiled_select([string
- $table = '',
- [boolean
- $reset = TRUE]] )
-
- $table
- —
- string$reset
- —
- boolean
-
- QueryBuilderInterface
-
-
public function get_compiled_update([string
- $table = '',
- [boolean
- $reset = TRUE]] )
-
- $table
- —
- string$reset
- —
- boolean
-
- QueryBuilderInterface
-
-
public function get_where(string
- $table,
- [array
- $where = ,
- [boolean
- $limit = FALSE,
- [boolean
- $offset = FALSE]]] )
-
- $table
- —
- string$where
- —
- array$limit
- —
- boolean$offset
- —
- boolean
-
- QueryBuilderInterface
-
-
public function group_by(mixed
- $field )
-
- $field
- —
- mixed
-
- QueryBuilderInterface
-
-
public function group_end()
-
-
-
- QueryBuilderInterface
-
-
public function group_start()
-
-
-
- QueryBuilderInterface
-
-
public function having(mixed
- $key,
- [array
- $val = ] )
-
- $key
- —
- mixed$val
- —
- array
-
- QueryBuilderInterface
-
-
public function insert(string
- $table,
- [array
- $data = ] )
-
- $table
- —
- string$data
- —
- array
-
- QueryBuilderInterface
-
-
public function insert_batch(string
- $table,
- [array
- $data = ] )
-
- $table
- —
- string$data
- —
- array
-
- QueryBuilderInterface
-
-
public function join(string
- $table,
- string
- $condition,
- [string
- $type = ''] )
-
- $table
- —
- string$condition
- —
- string$type
- —
- string
-
- QueryBuilderInterface
-
-
public function like(string
- $field,
- mixed
- $val,
- [string
- $pos = 'both'] )
-
- $field
- —
- string$val
- —
- mixed$pos
- —
- string
-
- QueryBuilderInterface
-
-
public function limit(int
- $limit,
- [boolean
- $offset = FALSE] )
-
- $limit
- —
- int$offset
- —
- boolean
-
- QueryBuilderInterface
-
-
public function not_like(string
- $field,
- mixed
- $val,
- [string
- $pos = 'both'] )
-
- $field
- —
- string$val
- —
- mixed$pos
- —
- string
-
- QueryBuilderInterface
-
-
public function or_group_start()
-
-
-
- QueryBuilderInterface
-
-
public function or_having(mixed
- $key,
- [array
- $val = ] )
-
- $key
- —
- mixed$val
- —
- array
-
- QueryBuilderInterface
-
-
public function or_like(string
- $field,
- mixed
- $val,
- [string
- $pos = 'both'] )
-
- $field
- —
- string$val
- —
- mixed$pos
- —
- string
-
- QueryBuilderInterface
-
-
public function or_not_group_start()
-
-
-
- QueryBuilderInterface
-
-
public function or_not_like(string
- $field,
- mixed
- $val,
- [string
- $pos = 'both'] )
-
- $field
- —
- string$val
- —
- mixed$pos
- —
- string
-
- QueryBuilderInterface
-
-
public function or_where(string
- $key,
- [array
- $val = ] )
-
- $key
- —
- string$val
- —
- array
-
- QueryBuilderInterface
-
-
public function or_where_in(string
- $field,
- [array
- $val = ] )
-
- $field
- —
- string$val
- —
- array
-
- QueryBuilderInterface
-
-
public function or_where_not_in(string
- $field,
- [array
- $val = ] )
-
- $field
- —
- string$val
- —
- array
-
- QueryBuilderInterface
-
-
public function order_by(string
- $field,
- [string
- $type = ""] )
-
- $field
- —
- string$type
- —
- string
-
- QueryBuilderInterface
-
-
public function reset_query()
-
-
-
- QueryBuilderInterface
-
-
public function select(string
- $fields )
-
- $fields
- —
- string
-
- QueryBuilderInterface
-
-
public function select_avg(string
- $field,
- [boolean
- $as = FALSE] )
-
- $field
- —
- string$as
- —
- boolean
-
- QueryBuilderInterface
-
-
public function select_max(string
- $field,
- [boolean
- $as = FALSE] )
-
- $field
- —
- string$as
- —
- boolean
-
- QueryBuilderInterface
-
-
public function select_min(string
- $field,
- [boolean
- $as = FALSE] )
-
- $field
- —
- string$as
- —
- boolean
-
- QueryBuilderInterface
-
-
public function select_sum(string
- $field,
- [boolean
- $as = FALSE] )
-
- $field
- —
- string$as
- —
- boolean
-
- QueryBuilderInterface
-
-
public function set(mixed
- $key,
- [mixed
- $val = NULL] )
-
- $key
- —
- mixed$val
- —
- mixed
-
- QueryBuilderInterface
-
-
public function update(string
- $table,
- [array
- $data = ] )
-
- $table
- —
- string$data
- —
- array
-
- QueryBuilderInterface
-
-
public function where(mixed
- $key,
- [array
- $val = ,
- [mixed
- $escape = NULL]] )
-
- $key
- —
- mixed$val
- —
- array$escape
- —
- mixed
-
- QueryBuilderInterface
-
-
public function where_in(mixed
- $field,
- [array
- $val = ] )
-
- $field
- —
- mixed$val
- —
- array
-
- QueryBuilderInterface
-
-
public function where_not_in(string
- $field,
- [array
- $val = ] )
-
- $field
- —
- string$val
- —
- array
-
- QueryBuilderInterface
-
-
Methods | -100% | -4 / 4 | -
Lines | -100% | -23 / 23 | -
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Change test setup to be more extensible-
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Actually fix tests-
- Author: Timothy J Warren (tim@timshomepage.net) / - Commiter: Timothy J Warren (tim@timshomepage.net) -
-Make class names Pascal Case-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Re-add some missing tests, and update README-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Move library into src folder, fix simpletest test runner-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update docs-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize drivers into a more modern layout-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Reorganize classes to autoload by namespace-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix some more docblocks-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Docblock fixes and more dependency injection-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Add insert_batch methods to Firebird and SQLite-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-A little cleanup of parser and connection code-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Namespaces!-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Update docs, composer and README-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Fix some docblocks, and update test files to 2014-
- Author: Timothy J. Warren (tim@timshomepage.net) / - Commiter: Timothy J. Warren (tim@timshomepage.net) -
-Improve code coverage-
public function __construct(DriverInterface
- $db )
-
- $db
- —
- Query\Driver\DriverInterfacepublic function compile_join(string
- $condition )
-
- $condition
- —
- stringprotected function filter_array(array
- $array )
-
- $array
- —
- arraypublic function parse_join(string
- $sql )
-
- $sql
- —
- string+ + + + +
AbstractQueryBuilder | +Abstract Class for internal implementation methods of the Query Builder | +
+ + + + +
BadDBDriverException | +Generic exception for bad drivers | +
+ + + + +
ConnectionManager | +Connection manager class to manage connections for the +Query method | +
+ + + + +
AbstractDriver | +Base Database class | +
+ + + + +
AbstractSQL | +parent for database manipulation subclasses | +
+ + + + +
AbstractUtil | +Abstract class defining database / table creation methods | +
+ + + +
DriverInterface | +PDO Interface to implement for database drivers | +
+ + + + +
Driver | +Firebird Database class | +
+ + + + +
Result | +Firebird result class to emulate PDOStatement Class - only implements +data-fetching methods | +
+ + + + +
Util | +Firebird-specific backup, import and creation methods | +
+ + + + +
Util | +MySQL-specific backup, import and creation methods | +
+ + + +
PDOInterface | +Interface describing the PDO class in PHP | +
+ + + +
PDOStatementInterface | +Interface created from official PHP Documentation | +
+ + + + +
Driver | +PostgreSQL specific class | +
+ + + + +
Util | +Posgres-specific backup, import and creation methods | +
+ + + +
SQLInterface | +parent for database manipulation subclasses | +
+ + + + +
Driver | +SQLite specific class | +
+ + + + +
Util | +SQLite-specific backup, import and creation methods | +
+ + + + +
QueryBuilder | +Convenience class for creating sql queries | +
+ + + +
QueryBuilderInterface | +Interface defining the Query Builder class | +
+ + + + +
QueryParser | +Utility Class to parse sql clauses for properly escaping identifiers | +
Query(string|object|array $params = '') : \Query\QueryBuilder|null
+ Connection function
+Send an array or object as connection parameters to create a connection. If +the array or object has an 'alias' parameter, passing that string to this +function will return that connection. Passing no parameters returns the last +connection created.
+ +string|object|array | +$params | ++ |
Name | -Description | -
---|---|
- Traversable - | -- No description available - | -
Name | -Description | -
---|---|
- DriverInterface - | -PDO Interface to implement for database drivers | -
- QueryBuilderInterface - | -Interface defining the Query Builder class | -
- SQLInterface - | -parent for database manipulation subclasses | -
public function __construct(string
- $dsn,
- [string
- $username = NULL,
- [string
- $password = NULL,
- [array
- $driver_options = ]]] )
-
- $dsn
- —
- string$username
- —
- string$password
- —
- string$driver_options
- —
- arraypublic function affected_rows()
-
- public function beginTransaction()
-
- public function commit()
-
- public function driver_query(string|array|null
- $query,
- [boolean
- $filtered_index = TRUE] )
-
- $query
- —
- object$filtered_index
- —
- booleanpublic function errorCode()
-
- public function errorInfo()
-
- public function exec(string
- $statement )
-
- $statement
- —
- stringpublic function getAttribute(int
- $attribute )
-
- $attribute
- —
- intpublic function get_columns(string
- $table )
-
- $table
- —
- stringpublic function get_dbs()
-
- public function get_fks(string
- $table )
-
- $table
- —
- stringpublic function get_functions()
-
- public function get_indexes(string
- $table )
-
- $table
- —
- stringpublic function get_procedures()
-
- public function get_sequences()
-
- public function get_sql()
-
- public function get_system_tables()
-
- public function get_tables()
-
- public function get_triggers()
-
- public function get_types()
-
- public function get_util()
-
- public function get_views()
-
- public function insert_batch(string
- $table,
- [array
- $data = ] )
-
- $table
- —
- string$data
- —
- arraypublic function num_rows()
-
- public function prefix_table(string
- $table )
-
- $table
- —
- stringpublic function prepare_execute(string
- $sql,
- array
- $params )
-
- $sql
- —
- string$params
- —
- arraypublic function prepare_query(string
- $sql,
- array
- $data )
-
- $sql
- —
- string$data
- —
- array
- InvalidArgumentException
-
- public function quote_ident(string|array
- $ident )
-
- $ident
- —
- objectpublic function quote_table(string|array
- $table )
-
- $table
- —
- objectpublic function rollback()
-
- public function setAttribute(int
- $attribute,
- mixed
- $value )
-
- $attribute
- —
- int$value
- —
- mixedpublic function count_all(string
- $table )
-
- $table
- —
- stringpublic function count_all_results([string
- $table = ''] )
-
- $table
- —
- stringpublic function delete(string
- $table,
- [string
- $where = ''] )
-
- $table
- —
- string$where
- —
- stringpublic function distinct()
-
- public function explain()
-
- public function from(string
- $tblname )
-
- $tblname
- —
- stringpublic function get([string
- $table = '',
- [boolean
- $limit = FALSE,
- [boolean
- $offset = FALSE]]] )
-
- $table
- —
- string$limit
- —
- boolean$offset
- —
- booleanpublic function get_compiled_delete([string
- $table = "",
- [boolean
- $reset = TRUE]] )
-
- $table
- —
- string$reset
- —
- booleanpublic function get_compiled_insert(string
- $table,
- [boolean
- $reset = TRUE] )
-
- $table
- —
- string$reset
- —
- booleanpublic function get_compiled_select([string
- $table = '',
- [boolean
- $reset = TRUE]] )
-
- $table
- —
- string$reset
- —
- booleanpublic function get_compiled_update([string
- $table = '',
- [boolean
- $reset = TRUE]] )
-
- $table
- —
- string$reset
- —
- booleanpublic function get_where(string
- $table,
- [array
- $where = ,
- [boolean
- $limit = FALSE,
- [boolean
- $offset = FALSE]]] )
-
- $table
- —
- string$where
- —
- array$limit
- —
- boolean$offset
- —
- booleanpublic function group_by(mixed
- $field )
-
- $field
- —
- mixedpublic function group_end()
-
- public function group_start()
-
- public function having(mixed
- $key,
- [array
- $val = ] )
-
- $key
- —
- mixed$val
- —
- arraypublic function insert(string
- $table,
- [array
- $data = ] )
-
- $table
- —
- string$data
- —
- arraypublic function insert_batch(string
- $table,
- [array
- $data = ] )
-
- $table
- —
- string$data
- —
- arraypublic function join(string
- $table,
- string
- $condition,
- [string
- $type = ''] )
-
- $table
- —
- string$condition
- —
- string$type
- —
- stringpublic function like(string
- $field,
- mixed
- $val,
- [string
- $pos = 'both'] )
-
- $field
- —
- string$val
- —
- mixed$pos
- —
- stringpublic function limit(int
- $limit,
- [boolean
- $offset = FALSE] )
-
- $limit
- —
- int$offset
- —
- booleanpublic function not_like(string
- $field,
- mixed
- $val,
- [string
- $pos = 'both'] )
-
- $field
- —
- string$val
- —
- mixed$pos
- —
- stringpublic function or_group_start()
-
- public function or_having(mixed
- $key,
- [array
- $val = ] )
-
- $key
- —
- mixed$val
- —
- arraypublic function or_like(string
- $field,
- mixed
- $val,
- [string
- $pos = 'both'] )
-
- $field
- —
- string$val
- —
- mixed$pos
- —
- stringpublic function or_not_group_start()
-
- public function or_not_like(string
- $field,
- mixed
- $val,
- [string
- $pos = 'both'] )
-
- $field
- —
- string$val
- —
- mixed$pos
- —
- stringpublic function or_where(string
- $key,
- [array
- $val = ] )
-
- $key
- —
- string$val
- —
- arraypublic function or_where_in(string
- $field,
- [array
- $val = ] )
-
- $field
- —
- string$val
- —
- arraypublic function or_where_not_in(string
- $field,
- [array
- $val = ] )
-
- $field
- —
- string$val
- —
- arraypublic function order_by(string
- $field,
- [string
- $type = ""] )
-
- $field
- —
- string$type
- —
- stringpublic function reset_query()
-
- public function select(string
- $fields )
-
- $fields
- —
- stringpublic function select_avg(string
- $field,
- [boolean
- $as = FALSE] )
-
- $field
- —
- string$as
- —
- booleanpublic function select_max(string
- $field,
- [boolean
- $as = FALSE] )
-
- $field
- —
- string$as
- —
- booleanpublic function select_min(string
- $field,
- [boolean
- $as = FALSE] )
-
- $field
- —
- string$as
- —
- booleanpublic function select_sum(string
- $field,
- [boolean
- $as = FALSE] )
-
- $field
- —
- string$as
- —
- booleanpublic function set(mixed
- $key,
- [mixed
- $val = NULL] )
-
- $key
- —
- mixed$val
- —
- mixedpublic function update(string
- $table,
- [array
- $data = ] )
-
- $table
- —
- string$data
- —
- arraypublic function where(mixed
- $key,
- [array
- $val = ,
- [bool
- $escape = NULL]] )
-
- $key
- —
- mixed$val
- —
- array$escape
- —
- objectpublic function where_in(mixed
- $field,
- [array
- $val = ] )
-
- $field
- —
- mixed$val
- —
- arraypublic function where_not_in(string
- $field,
- [array
- $val = ] )
-
- $field
- —
- string$val
- —
- arraypublic function column_list(string
- $table )
-
- $table
- —
- stringpublic function db_list()
-
- public function explain(string
- $sql )
-
- $sql
- —
- stringpublic function fk_list(string
- $table )
-
- $table
- —
- stringpublic function function_list()
-
- public function index_list(string
- $table )
-
- $table
- —
- stringpublic function limit(string
- $sql,
- int
- $limit,
- [boolean
- $offset = FALSE] )
-
- $sql
- —
- string$limit
- —
- int$offset
- —
- booleanpublic function procedure_list()
-
- public function random()
-
- public function sequence_list()
-
- public function system_table_list()
-
- public function table_list()
-
- public function trigger_list()
-
- public function type_list()
-
- public function view_list()
-
- t |
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
error | +18 | +No summary for class \Query\State | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
error | +17 | +No summary for class \Query\DriverFactory | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
Type | +Line | +Description | +
---|---|---|
error | +0 | +No summary was found for this file | +
- Size: 15,192 Bytes - Last Modified: 2015-11-10T09:57:28-05:00
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
- Covered by 6 test(s):
- 84
- Covered by 6 test(s):
- 8586
- Covered by 6 test(s):
- 87
- Covered by 6 test(s):
- 888990919293949596979899
- Covered by 7 test(s):
- 100
- Covered by 7 test(s):
- 101
- Covered by 7 test(s):
- 102
- Covered by 7 test(s):
- 103
- Covered by 7 test(s):
- 104
- Covered by 7 test(s):
- 105106
- Covered by 7 test(s):
- 107
- Covered by 7 test(s):
- 108
- Covered by 7 test(s):
- 109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
- Covered by 55 test(s):
- 144145146147148149150151152153154155156
- Covered by 223 test(s):
- 157
- Covered by 223 test(s):
- 158159160161162163164165166167168
- Covered by 74 test(s):
- 169170171172173174175176177178179180
- Covered by 15 test(s):
- 181182183184185186187188189190191192193
- Covered by 3 test(s):
- 194
- Covered by 3 test(s):
- 195196197198199200201202203204205206207208209210211
- Covered by 119 test(s):
- 212213
- Covered by 119 test(s):
- 214
- Covered by 119 test(s):
- 215
- Covered by 2 test(s):
- 216217218219
- Covered by 117 test(s):
- 220221222223
- Covered by 117 test(s):
- 224
- Covered by 117 test(s):
- 225
- Covered by 117 test(s):
- 226227
- Covered by 117 test(s):
- 228229230231232233234235236237238239240241
- Covered by 114 test(s):
- 242
- Covered by 114 test(s):
- 243244
- Covered by 114 test(s):
- 245246247248249250251252253254255256257
- Covered by 1 test(s):
- 258259260261262263264265266267268269270271
- Covered by 257 test(s):
- 272
- Covered by 257 test(s):
- 273274275276277278
- Covered by 257 test(s):
- 279
- Covered by 257 test(s):
- 280281282
- Covered by 257 test(s):
- 283284285
- Covered by 257 test(s):
- 286
- Covered by 257 test(s):
- 287288
- Covered by 257 test(s):
- 289290291292293294295296297298299300301
- Covered by 249 test(s):
- 302303304
- Covered by 249 test(s):
- 305306307308309310311312313314315316317
- Covered by 249 test(s):
- 318
- Covered by 249 test(s):
- 319
- Covered by 192 test(s):
- 320321322323
- Covered by 249 test(s):
- 324
- Covered by 249 test(s):
- 325
- Covered by 4 test(s):
- 326
- Covered by 4 test(s):
- 327
- Covered by 4 test(s):
- 328
- Covered by 4 test(s):
- 329330331
- Covered by 249 test(s):
- 332
- Covered by 249 test(s):
- 333334335
- Covered by 249 test(s):
- 336337338
- Covered by 249 test(s):
- 339
- Covered by 249 test(s):
- 340
- Covered by 249 test(s):
- 341342343
- Covered by 4 test(s):
- 344345346
- Covered by 4 test(s):
- 347
- Covered by 249 test(s):
- 348349
- Covered by 249 test(s):
- 350351352353354355356357358359360361362
- Covered by 2 test(s):
- 363364365366367368369370371372373374
- Covered by 38 test(s):
- 375
- Covered by 38 test(s):
- 376
- Covered by 38 test(s):
- 377378379380381382383384385386387388
- Covered by 3 test(s):
- 389390391392393394395396397398399400
- Covered by 4 test(s):
- 401
- Covered by 4 test(s):
- 402
- Covered by 4 test(s):
- 403404405406407408409410411412413414
- Covered by 4 test(s):
- 415416417418419420421422423424425426
- Covered by 4 test(s):
- 427428429430431432433434435436437438
- Covered by 4 test(s):
- 439440441442443444445446447448449450
- Covered by 4 test(s):
- 451452453454455456457458459460461462463
- Covered by 4 test(s):
- 464465466467468469470471472473474475476
- Covered by 4 test(s):
- 477478479480481482483484485486487488489
- Covered by 4 test(s):
- 490491492493494495496497498499500501502
- Covered by 4 test(s):
- 503504505506507508509510511512513514
- Covered by 4 test(s):
- 515516517518519520521522523524525526527528529
- Covered by 72 test(s):
- 530
- Covered by 72 test(s):
- 531
- Covered by 62 test(s):
- 532
- Covered by 62 test(s):
- 533534535536
- Covered by 72 test(s):
- 537538539
- Covered by 65 test(s):
- 540541
- Covered by 65 test(s):
- 542
- Covered by 65 test(s):
- 543544
- Covered by 65 test(s):
- 545546547548549550551552553554555556557
- Covered by 12 test(s):
- 558
- Covered by 12 test(s):
- 559560
- Covered by 12 test(s):
- 561
- Covered by 12 test(s):
- 562
- Covered by 8 test(s):
- 563
- Covered by 8 test(s):
- 564565566
- Covered by 4 test(s):
- 567568569570571572573574575576577578579580
- Covered by 3 test(s):
- 581
- Covered by 3 test(s):
- 582583584
- Covered by 3 test(s):
- 585
- Covered by 3 test(s):
- 586587
- Covered by 3 test(s):
- 588
- Covered by 3 test(s):
- 589
- Covered by 3 test(s):
- 590
- Covered by 3 test(s):
- 591592
- Covered by 3 test(s):
- 593
- Covered by 3 test(s):
- 594
- Covered by 3 test(s):
- 595596597
- Covered by 3 test(s):
- 598
- Covered by 3 test(s):
- 599
- Covered by 3 test(s):
- 600601602
- Covered by 3 test(s):
- 603604
- Covered by 3 test(s):
- 605606607608609610611612613614615616617618619620621
- Covered by 249 test(s):
- 622
- Covered by 249 test(s):
- 623
- Covered by 249 test(s):
- 624
- Covered by 249 test(s):
- 625
- Covered by 249 test(s):
- 626
- Covered by 249 test(s):
- 627628629630631632633634635636637638639640641
- Covered by 257 test(s):
- 642
- Covered by 257 test(s):
- 643
- Covered by 9 test(s):
- 644645646
- Covered by 248 test(s):
- 647648649650651652653654655656657658659
- Covered by 4 test(s):
- 660
- Covered by 4 test(s):
- 661
- Covered by 4 test(s):
- 662663
- Covered by 4 test(s):
- 664665
- Covered by 4 test(s):
- 666
- Covered by 4 test(s):
- 667668669670
- Covered by 1 test(s):
-
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query; // -------------------------------------------------------------------------- /** * Base Database class * * Extends PDO to simplify cross-database issues * * @package Query * @subpackage Drivers */ abstract class AbstractDriver extends \PDO implements DriverInterface { /** * Reference to the last executed query * @var \PDOStatement */ protected $statement; /** * Character to escape identifiers * @var string */ protected $escape_char = '"'; /** * Reference to sql class * @var SQL_Interface */ protected $sql; /** * Reference to util class * @var Abstract_Util */ protected $util; /** * Last query executed * @var string */ protected $last_query; /** * Prefix to apply to table names * @var string */ protected $table_prefix = ''; /** * Whether the driver supports 'TRUNCATE' * @var bool */ protected $has_truncate = TRUE; /** * PDO constructor wrapper * * @param string $dsn * @param string $username * @param string $password * @param array $driver_options */ public function __construct($dsn, $username=NULL, $password=NULL, array $driver_options=array()) { // Set PDO to display errors as exceptions, and apply driver options $driver_options[\PDO::ATTR_ERRMODE] = \PDO::ERRMODE_EXCEPTION; parent::__construct($dsn, $username, $password, $driver_options); $this->_load_sub_classes(); } // -------------------------------------------------------------------------- /** * Loads the subclasses for the driver * * @return void */ protected function _load_sub_classes() { // Load the sql and util class for the driver $this_class = get_class($this); $ns_array = explode("\\", $this_class); array_pop($ns_array); $driver = array_pop($ns_array); $sql_class = "\\Query\\Drivers\\{$driver}\\SQL"; $util_class = "\\Query\\Drivers\\{$driver}\\Util"; $this->sql = new $sql_class(); $this->util = new $util_class($this); } // -------------------------------------------------------------------------- /** * Allow invoke to work on table object * * @codeCoverageIgnore * @param string $name * @param array $args * @return mixed */ public function __call($name, $args = array()) { if ( isset($this->$name) && is_object($this->$name) && method_exists($this->$name, '__invoke') ) { return call_user_func_array(array($this->$name, '__invoke'), $args); } } // -------------------------------------------------------------------------- // ! Accessors / Mutators // -------------------------------------------------------------------------- /** * Get the last sql query exexcuted * * @return string */ public function get_last_query() { return $this->last_query; } // -------------------------------------------------------------------------- /** * Set the last query sql * * @param string $query_string * @return void */ public function set_last_query($query_string) { $this->last_query = $query_string; } // -------------------------------------------------------------------------- /** * Get the SQL class for the current driver * * @return SQL_Interface */ public function get_sql() { return $this->sql; } // -------------------------------------------------------------------------- /** * Get the Util class for the current driver * * @return Abstract_Util */ public function get_util() { return $this->util; } // -------------------------------------------------------------------------- /** * Set the common table name prefix * * @param string $prefix * @return void */ public function set_table_prefix($prefix) { $this->table_prefix = $prefix; } // -------------------------------------------------------------------------- // ! Concrete functions that can be overridden in child classes // -------------------------------------------------------------------------- /** * Simplifies prepared statements for database queries * * @param string $sql * @param array $data * @return \PDOStatement | FALSE * @throws \InvalidArgumentException */ public function prepare_query($sql, $data) { // Prepare the sql, save the statement for easy access later $this->statement = $this->prepare($sql); if( ! (is_array($data) || is_object($data))) { throw new \InvalidArgumentException("Invalid data argument"); } // Bind the parameters foreach($data as $k => $value) { // Parameters are 1-based, the data is 0-based // So, if the key is numeric, add 1 if(is_numeric($k)) $k++; $this->statement->bindValue($k, $value); } return $this->statement; } // ------------------------------------------------------------------------- /** * Create and execute a prepared statement with the provided parameters * * @param string $sql * @param array $params * @return \PDOStatement */ public function prepare_execute($sql, $params) { $this->statement = $this->prepare_query($sql, $params); $this->statement->execute(); return $this->statement; } // ------------------------------------------------------------------------- /** * Returns number of rows affected by an INSERT, UPDATE, DELETE type query * * @return int */ public function affected_rows() { // Return number of rows affected return $this->statement->rowCount(); } // -------------------------------------------------------------------------- /** * Prefixes a table if it is not already prefixed * @param string $table * @return string */ public function prefix_table($table) { // Add the prefix to the table name // before quoting it if ( ! empty($this->table_prefix)) { // Split identifier by period, will split into: // database.schema.table OR // schema.table OR // database.table OR // table $idents = explode('.', $table); $segments = count($idents); // Quote the last item, and add the database prefix $idents[$segments - 1] = $this->_prefix(end($idents)); // Rejoin $table = implode('.', $idents); } return $table; } // -------------------------------------------------------------------------- /** * Quote database table name, and set prefix * * @param string $table * @return string */ public function quote_table($table) { $table = $this->prefix_table($table); // Finally, quote the table return $this->quote_ident($table); } // -------------------------------------------------------------------------- /** * Surrounds the string with the databases identifier escape characters * * @param mixed $ident * @return string */ public function quote_ident($ident) { if (is_array($ident)) { return array_map(array($this, __METHOD__), $ident); } // Handle comma-separated identifiers if (strpos($ident, ',') !== FALSE) { $parts = array_map('mb_trim', explode(',', $ident)); $parts = array_map(array($this, __METHOD__), $parts); $ident = implode(',', $parts); } // Split each identifier by the period $hiers = explode('.', $ident); $hiers = array_map('mb_trim', $hiers); // Re-compile the string $raw = implode('.', array_map(array($this, '_quote'), $hiers)); // Fix functions $funcs = array(); preg_match_all("#{$this->escape_char}([a-zA-Z0-9_]+(\((.*?)\))){$this->escape_char}#iu", $raw, $funcs, PREG_SET_ORDER); foreach($funcs as $f) { // Unquote the function $raw = str_replace($f[0], $f[1], $raw); // Quote the inside identifiers $raw = str_replace($f[3], $this->quote_ident($f[3]), $raw); } return $raw; } // ------------------------------------------------------------------------- /** * Return schemas for databases that list them * * @return array */ public function get_schemas() { return NULL; } // ------------------------------------------------------------------------- /** * Return list of tables for the current database * * @return array */ public function get_tables() { $tables = $this->driver_query('table_list'); natsort($tables); return $tables; } // ------------------------------------------------------------------------- /** * Return list of dbs for the current connection, if possible * * @return array */ public function get_dbs() { return $this->driver_query('db_list'); } // ------------------------------------------------------------------------- /** * Return list of views for the current database * * @return array */ public function get_views() { $views = $this->driver_query('view_list'); sort($views); return $views; } // ------------------------------------------------------------------------- /** * Return list of sequences for the current database, if they exist * * @return array */ public function get_sequences() { return $this->driver_query('sequence_list'); } // ------------------------------------------------------------------------- /** * Return list of functions for the current database * * @return array */ public function get_functions() { return $this->driver_query('function_list', FALSE); } // ------------------------------------------------------------------------- /** * Return list of stored procedures for the current database * * @return array */ public function get_procedures() { return $this->driver_query('procedure_list', FALSE); } // ------------------------------------------------------------------------- /** * Return list of triggers for the current database * * @return array */ public function get_triggers() { return $this->driver_query('trigger_list', FALSE); } // ------------------------------------------------------------------------- /** * Retrieves an array of non-user-created tables for * the connection/database * * @return array */ public function get_system_tables() { return $this->driver_query('system_table_list'); } // -------------------------------------------------------------------------- /** * Retrieve column information for the current database table * * @param string $table * @return array */ public function get_columns($table) { return $this->driver_query($this->get_sql()->column_list($this->prefix_table($table)), FALSE); } // -------------------------------------------------------------------------- /** * Retrieve foreign keys for the table * * @param string $table * @return array */ public function get_fks($table) { return $this->driver_query($this->get_sql()->fk_list($table), FALSE); } // -------------------------------------------------------------------------- /** * Retrieve indexes for the table * * @param string $table * @return array */ public function get_indexes($table) { return $this->driver_query($this->get_sql()->index_list($this->prefix_table($table)), FALSE); } // -------------------------------------------------------------------------- /** * Retrieve list of data types for the database * * @return array */ public function get_types() { return $this->driver_query('type_list', FALSE); } // ------------------------------------------------------------------------- /** * Method to simplify retrieving db results for meta-data queries * * @param string|array|null $query * @param bool $filtered_index * @return array */ public function driver_query($query, $filtered_index=TRUE) { // Call the appropriate method, if it exists if (is_string($query) && method_exists($this->sql, $query)) { $query = $this->get_sql()->$query(); } // Return if the values are returned instead of a query, // or if the query doesn't apply to the driver if ( ! is_string($query)) return $query; // Run the query! $res = $this->query($query); $flag = ($filtered_index) ? \PDO::FETCH_NUM : \PDO::FETCH_ASSOC; $all = $res->fetchAll($flag); return ($filtered_index) ? \db_filter($all, 0) : $all; } // -------------------------------------------------------------------------- /** * Return the number of rows returned for a SELECT query * * @see http://us3.php.net/manual/en/pdostatement.rowcount.php#87110 * @return int */ public function num_rows() { $regex = '/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/i'; $output = array(); if (preg_match($regex, $this->last_query, $output) > 0) { $stmt = $this->query("SELECT COUNT(*) FROM {$output[1]}"); return (int) $stmt->fetchColumn(); } return NULL; } // -------------------------------------------------------------------------- /** * Create sql for batch insert * * @param string $table * @param array $data * @return null|array<string|array|null> */ public function insert_batch($table, $data=array()) { $first_row = current($data); if ( ! is_array($first_row)) return NULL; // Values for insertion $vals = array(); foreach($data as $group) { $vals = array_merge($vals, array_values($group)); } $table = $this->quote_table($table); $fields = array_keys($first_row); $sql = "INSERT INTO {$table} (" . implode(',', $this->quote_ident($fields)) . ") VALUES "; // Create the placeholder groups $params = array_fill(0, count($fields), '?'); $param_string = "(" . implode(',', $params) . ")"; $param_list = array_fill(0, count($data), $param_string); // Append the placeholder groups to the query $sql .= implode(',', $param_list); return array($sql, $vals); } // -------------------------------------------------------------------------- /** * Helper method for quote_ident * * @param mixed $str * @return mixed */ public function _quote($str) { // Check that the current value is a string, // and is not already quoted before quoting // that value, otherwise, return the original value return ( is_string($str) && strpos($str, $this->escape_char) !== 0 && strrpos($str, $this->escape_char) !== 0 ) ? "{$this->escape_char}{$str}{$this->escape_char}" : $str; } // -------------------------------------------------------------------------- /** * Sets the table prefix on the passed string * * @param string $str * @return string */ protected function _prefix($str) { // Don't prefix an already prefixed table if (strpos($str, $this->table_prefix) !== FALSE) { return $str; } return $this->table_prefix.$str; } // ------------------------------------------------------------------------- /** * Empty the passed table * * @param string $table * @return \PDOStatement */ public function truncate($table) { $sql = ($this->has_truncate) ? 'TRUNCATE ' : 'DELETE FROM '; $sql .= $this->quote_table($table); $this->statement = $this->query($sql); return $this->statement; } } // End of db_pdo.php |
- Size: 13,376 Bytes - Last Modified: 2015-11-10T09:57:49-05:00
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
- Covered by 128 test(s):
- 198
- Covered by 128 test(s):
- 199
- Covered by 128 test(s):
- 200201
- Covered by 128 test(s):
- 202203
- Covered by 128 test(s):
- 204
- Covered by 128 test(s):
- 205
- Covered by 128 test(s):
- 206
- Covered by 128 test(s):
- 207
- Covered by 32 test(s):
- 208
- Covered by 128 test(s):
- 209210211
- Covered by 108 test(s):
- 212213
- Covered by 128 test(s):
- 214215
- Covered by 128 test(s):
- 216217218219220221222223224225226227228229230
- Covered by 20 test(s):
- 231232
- Covered by 20 test(s):
- 233234235
- Covered by 20 test(s):
- 236
- Covered by 20 test(s):
- 237238239240241242243244245246247248249250251
- Covered by 17 test(s):
- 252253254
- Covered by 17 test(s):
- 255256
- Covered by 17 test(s):
- 257258259260261262263264265266267268269270271272273
- Covered by 24 test(s):
- 274275276
- Covered by 24 test(s):
- 277278
- Covered by 24 test(s):
- 279
- Covered by 24 test(s):
- 280
- Covered by 12 test(s):
- 281
- Covered by 12 test(s):
- 282
- Covered by 20 test(s):
- 283284
- Covered by 4 test(s):
- 285
- Covered by 4 test(s):
- 286287288
- Covered by 16 test(s):
- 289290291
- Covered by 24 test(s):
- 292
- Covered by 24 test(s):
- 293294295
- Covered by 24 test(s):
- 296297
- Covered by 24 test(s):
- 298299300301302303304305306307308309310311312
- Covered by 8 test(s):
- 313314315
- Covered by 8 test(s):
- 316317318319
- Covered by 8 test(s):
- 320321
- Covered by 8 test(s):
- 322323324
- Covered by 8 test(s):
- 325326327
- Covered by 8 test(s):
- 328
- Covered by 8 test(s):
- 329330
- Covered by 8 test(s):
- 331
- Covered by 8 test(s):
- 332333
- Covered by 8 test(s):
- 334335336337338339340341342343344345346347
- Covered by 108 test(s):
- 348
- Covered by 108 test(s):
- 349
- Covered by 108 test(s):
- 350
- Covered by 108 test(s):
- 351352353354355356357358359360361362363364365366
- Covered by 100 test(s):
- 367368369370
- Covered by 100 test(s):
- 371372
- Covered by 100 test(s):
- 373374375
- Covered by 100 test(s):
- 376
- Covered by 100 test(s):
- 377378379
- Covered by 100 test(s):
- 380
- Covered by 100 test(s):
- 381
- Covered by 100 test(s):
- 382
- Covered by 84 test(s):
- 383
- Covered by 84 test(s):
- 384
- Covered by 52 test(s):
- 385386
- Covered by 16 test(s):
- 387
- Covered by 16 test(s):
- 388389390
- Covered by 52 test(s):
- 391392393
- Covered by 100 test(s):
- 394
- Covered by 100 test(s):
- 395396
- Covered by 100 test(s):
- 397398399400401402403404405406407408409410411412
- Covered by 16 test(s):
- 413
- Covered by 16 test(s):
- 414415
- Covered by 16 test(s):
- 416417
- Covered by 16 test(s):
- 418
- Covered by 16 test(s):
- 419420
- Covered by 16 test(s):
- 421
- Covered by 16 test(s):
- 422423
- Covered by 16 test(s):
- 424425
- Covered by 16 test(s):
- 426427428429430431432433434435436437438439440441
- Covered by 223 test(s):
- 442
- Covered by 223 test(s):
- 443
- Covered by 219 test(s):
- 444
- Covered by 219 test(s):
- 445446
- Covered by 223 test(s):
- 447
- Covered by 223 test(s):
- 448
- Covered by 220 test(s):
- 449
- Covered by 220 test(s):
- 450451
- Covered by 223 test(s):
- 452453
- Covered by 223 test(s):
- 454
- Covered by 223 test(s):
- 455
- Covered by 223 test(s):
- 456457
- Covered by 223 test(s):
- 458
- Covered by 223 test(s):
- 459460461
- Covered by 223 test(s):
- 462463464
- Covered by 223 test(s):
- 465466
- Covered by 223 test(s):
- 467468469470471472473474475476477478479480481
- Covered by 140 test(s):
- 482
- Covered by 140 test(s):
- 483
- Covered by 140 test(s):
- 484485
- Covered by 140 test(s):
- 486
- Covered by 140 test(s):
- 487488489490491492493494495496497498499500
- Covered by 223 test(s):
- 501
- Covered by 223 test(s):
- 502503504
- Covered by 223 test(s):
- 505506
- Covered by 146 test(s):
- 507
- Covered by 223 test(s):
- 508509510511
- Covered by 223 test(s):
- 512513514
- Covered by 223 test(s):
- 515
- Covered by 223 test(s):
- 516
- Covered by 223 test(s):
- 517518519
- Covered by 223 test(s):
- 520521522
- Covered by 223 test(s):
- 523
- Covered by 223 test(s):
- 524525526527528529530531532533534535536
- Covered by 232 test(s):
- 537
- Covered by 232 test(s):
- 538
- Covered by 16 test(s):
- 539
- Covered by 16 test(s):
- 540
- Covered by 16 test(s):
- 541
- Covered by 16 test(s):
- 542
- Covered by 16 test(s):
- 543
- Covered by 16 test(s):
- 544
- Covered by 216 test(s):
- 545546
- Covered by 16 test(s):
- 547
- Covered by 16 test(s):
- 548
- Covered by 200 test(s):
- 549550
- Covered by 12 test(s):
- 551
- Covered by 12 test(s):
- 552553554
- Covered by 188 test(s):
- 555556557
- Covered by 188 test(s):
- 558
- Covered by 188 test(s):
- 559560
- Covered by 92 test(s):
- 561
- Covered by 92 test(s):
- 562563564
- Covered by 232 test(s):
- 565566567568569570571572573574575576577578579
- Covered by 232 test(s):
- 580581582
- Covered by 232 test(s):
- 583
- Covered by 232 test(s):
- 584
- Covered by 232 test(s):
- 585
- Covered by 232 test(s):
- 586
- Covered by 232 test(s):
- 587588589
- Covered by 232 test(s):
- 590591
- Covered by 232 test(s):
- 592
- Covered by 232 test(s):
- 593
- Covered by 232 test(s):
- 594
- Covered by 232 test(s):
- 595596
- Covered by 148 test(s):
- 597
- Covered by 232 test(s):
- 598
- Covered by 232 test(s):
- 599600601
- Covered by 232 test(s):
- 602603
- Covered by 232 test(s):
- 604605606
- Covered by 232 test(s):
- 607
- Covered by 232 test(s):
- 608
- Covered by 68 test(s):
- 609
- Covered by 68 test(s):
- 610611612613
- Covered by 232 test(s):
- 614
- Covered by 232 test(s):
- 615
- Covered by 4 test(s):
- 616
- Covered by 4 test(s):
- 617618
- Covered by 232 test(s):
- 619620621622
- Covered by 1 test(s):
-
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query; // -------------------------------------------------------------------------- /** * Abstract Class for internal implementation methods of the Query Builder * @package Query */ abstract class AbstractQueryBuilder { // -------------------------------------------------------------------------- // ! Constants // -------------------------------------------------------------------------- const KEY = 0; const VALUE = 1; const BOTH = 2; // -------------------------------------------------------------------------- // ! SQL Clause Strings // -------------------------------------------------------------------------- /** * Compiled 'select' clause * @var string */ protected $select_string = ''; /** * Compiled 'from' clause * @var string */ protected $from_string; /** * Compiled arguments for insert / update * @var string */ protected $set_string; /** * Order by clause * @var string */ protected $order_string; /** * Group by clause * @var string */ protected $group_string; // -------------------------------------------------------------------------- // ! SQL Clause Arrays // -------------------------------------------------------------------------- /** * Keys for insert/update statement * @var array */ protected $set_array_keys = array(); /** * Key/val pairs for order by clause * @var array */ protected $order_array = array(); /** * Key/val pairs for group by clause * @var array */ protected $group_array = array(); // -------------------------------------------------------------------------- // ! Other Class vars // -------------------------------------------------------------------------- /** * Values to apply to prepared statements * @var array */ protected $values = array(); /** * Values to apply to where clauses in prepared statements * @var array */ protected $where_values = array(); /** * Value for limit string * @var string */ protected $limit; /** * Value for offset in limit string * @var int */ protected $offset; /** * Query component order mapping * for complex select queries * * Format: * array( * 'type' => 'where', * 'conjunction' => ' AND ', * 'string' => 'k=?' * ) * * @var array */ protected $query_map = array(); /** * Map for having clause * @var array */ protected $having_map; /** * Convenience property for connection management * @var string */ public $conn_name = ""; /** * List of queries executed * @var array */ public $queries; /** * Whether to do only an explain on the query * @var bool */ protected $explain; /** * The current database driver * @var Driver_Interface */ public $db; /** * Query parser class instance * @var Query_Parser */ public $parser; /** * Alias to driver util class * @var \Query\Driver\Abstract_Util */ public $util; /** * Alias to driver sql class * @var \Query\Driver\SQL_Interface */ public $sql; // -------------------------------------------------------------------------- // Methods // -------------------------------------------------------------------------- /** * Set values in the class, with either an array or key value pair * * @param array $var * @param mixed $key * @param mixed $val * @param int $val_type * @return array */ protected function _mixed_set(&$var, $key, $val=NULL, $val_type=self::BOTH) { $arg = (is_scalar($key) && is_scalar($val)) ? array($key => $val) : $key; foreach($arg as $k => $v) { if (in_array($val_type, array(self::KEY, self::VALUE))) { $var[] = ($val_type === self::KEY) ? $k : $v; } else { $var[$k] = $v; } } return $var; } // -------------------------------------------------------------------------- /** * Method to simplify select_ methods * * @param string $field * @param string|bool $as * @return string */ protected function _select($field, $as = FALSE) { // Escape the identifiers $field = $this->db->quote_ident($field); if ( ! is_string($as)) return $field; $as = $this->db->quote_ident($as); return "({$field}) AS {$as} "; } // -------------------------------------------------------------------------- /** * Helper function for returning sql strings * * @param string $type * @param string $table * @param bool $reset * @return string */ protected function _get_compile($type, $table, $reset) { $sql = $this->_compile($type, $table); // Reset the query builder for the next query if ($reset) $this->reset_query(); return $sql; } // -------------------------------------------------------------------------- /** * Simplify 'like' methods * * @param string $field * @param mixed $val * @param string $pos * @param string $like * @param string $conj * @return Query_Builder */ protected function _like($field, $val, $pos, $like='LIKE', $conj='AND') { $field = $this->db->quote_ident($field); // Add the like string into the order map $like = $field. " {$like} ?"; if ($pos == 'before') { $val = "%{$val}"; } elseif ($pos == 'after') { $val = "{$val}%"; } else { $val = "%{$val}%"; } $conj = (empty($this->query_map)) ? ' WHERE ' : " {$conj} "; $this->_append_map($conj, $like, 'like'); // Add to the values array $this->where_values[] = $val; return $this; } // -------------------------------------------------------------------------- /** * Simplify building having clauses * * @param mixed $key * @param mixed $val * @param string $conj * @return Query_Builder */ protected function _having($key, $val=array(), $conj='AND') { $where = $this->_where($key, $val); // Create key/value placeholders foreach($where as $f => $val) { // Split each key by spaces, in case there // is an operator such as >, <, !=, etc. $f_array = explode(' ', trim($f)); $item = $this->db->quote_ident($f_array[0]); // Simple key value, or an operator $item .= (count($f_array) === 1) ? '=?' : " {$f_array[1]} ?"; // Put in the having map $this->having_map[] = array( 'conjunction' => ( ! empty($this->having_map)) ? " {$conj} " : ' HAVING ', 'string' => $item ); } return $this; } // -------------------------------------------------------------------------- /** * Do all the repeditive stuff for where/having type methods * * @param mixed $key * @param mixed $val * @return array */ protected function _where($key, $val=array()) { $where = array(); $this->_mixed_set($where, $key, $val, self::BOTH); $this->_mixed_set($this->where_values, $key, $val, self::VALUE); return $where; } // -------------------------------------------------------------------------- /** * Simplify generating where string * * @param mixed $key * @param mixed $val * @param string $defaultConj * @return Query_Builder */ protected function _where_string($key, $val=array(), $defaultConj='AND') { // Create key/value placeholders foreach($this->_where($key, $val) as $f => $val) { // Split each key by spaces, in case there // is an operator such as >, <, !=, etc. $f_array = explode(' ', trim($f)); $item = $this->db->quote_ident($f_array[0]); // Simple key value, or an operator $item .= (count($f_array) === 1) ? '=?' : " {$f_array[1]} ?"; $last_item = end($this->query_map); // Determine the correct conjunction $conjunctionList = array_pluck($this->query_map, 'conjunction'); if (empty($this->query_map) || ( ! regex_in_array($conjunctionList, "/^ ?\n?WHERE/i"))) { $conj = "\nWHERE "; } elseif ($last_item['type'] === 'group_start') { $conj = ''; } else { $conj = " {$defaultConj} "; } $this->_append_map($conj, $item, 'where'); } return $this; } // -------------------------------------------------------------------------- /** * Simplify where_in methods * * @param mixed $key * @param mixed $val * @param string $in - The (not) in fragment * @param string $conj - The where in conjunction * @return Query_Builder */ protected function _where_in($key, $val=array(), $in='IN', $conj='AND') { $key = $this->db->quote_ident($key); $params = array_fill(0, count($val), '?'); foreach($val as $v) { $this->where_values[] = $v; } $conjunction = ( ! empty($this->query_map)) ? " {$conj} " : ' WHERE '; $str = $key . " {$in} (".implode(',', $params).') '; $this->_append_map($conjunction, $str, 'where_in'); return $this; } // -------------------------------------------------------------------------- /** * Executes the compiled query * * @param string $type * @param string $table * @param string $sql * @param array|null $vals * @return \PDOStatement */ protected function _run($type, $table, $sql=NULL, $vals=NULL) { if (is_null($sql)) { $sql = $this->_compile($type, $table); } if (is_null($vals)) { $vals = array_merge($this->values, (array) $this->where_values); } $start_time = microtime(TRUE); $res = (empty($vals)) ? $this->db->query($sql) : $this->db->prepare_execute($sql, $vals); $end_time = microtime(TRUE); $total_time = number_format($end_time - $start_time, 5); // Add this query to the list of executed queries $this->_append_query($vals, $sql, $total_time); // Reset class state for next query $this->reset_query(); return $res; } // -------------------------------------------------------------------------- /** * Add an additional set of mapping pairs to a internal map * * @param string $conjunction * @param string $string * @param string $type * @return void */ protected function _append_map($conjunction = '', $string = '', $type = '') { array_push($this->query_map, array( 'type' => $type, 'conjunction' => $conjunction, 'string' => $string )); } // -------------------------------------------------------------------------- /** * Convert the prepared statement into readable sql * * @param array $vals * @param string $sql * @param string $total_time * @return void */ protected function _append_query($vals, $sql, $total_time) { $evals = (is_array($vals)) ? $vals : array(); $esql = str_replace('?', "%s", $sql); // Quote string values foreach($evals as &$v) { $v = ( ! is_numeric($v)) ? htmlentities($this->db->quote($v), ENT_NOQUOTES, 'utf-8') : $v; } // Add the query onto the array of values to pass // as arguments to sprintf array_unshift($evals, $esql); // Add the interpreted query to the list of executed queries $this->queries[] = array( 'time' => $total_time, 'sql' => call_user_func_array('sprintf', $evals), ); $this->queries['total_time'] += $total_time; // Set the last query to get rowcounts properly $this->db->set_last_query($sql); } // -------------------------------------------------------------------------- /** * Sub-method for generating sql strings * * @param string $type * @param string $table * @return string */ protected function _compile_type($type='', $table='') { if ($type === 'insert') { $param_count = count($this->set_array_keys); $params = array_fill(0, $param_count, '?'); $sql = "INSERT INTO {$table} (" . implode(',', $this->set_array_keys) . ")\nVALUES (".implode(',', $params).')'; } elseif ($type === 'update') { $sql = "UPDATE {$table}\nSET {$this->set_string}"; } elseif ($type === 'delete') { $sql = "DELETE FROM {$table}"; } else // GET queries { $sql = "SELECT * \nFROM {$this->from_string}"; // Set the select string if ( ! empty($this->select_string)) { // Replace the star with the selected fields $sql = str_replace('*', $this->select_string, $sql); } } return $sql; } // -------------------------------------------------------------------------- /** * String together the sql statements for sending to the db * * @param string $type * @param string $table * @return string */ protected function _compile($type='', $table='') { // Get the base clause for the query $sql = $this->_compile_type($type, $this->db->quote_table($table)); $clauses = array( 'query_map', 'group_string', 'order_string', 'having_map', ); // Set each type of subclause foreach($clauses as $clause) { $param = $this->$clause; if (is_array($param)) { foreach($param as $q) { $sql .= $q['conjunction'] . $q['string']; } } else { $sql .= $param; } } // Set the limit via the class variables if (is_numeric($this->limit)) { $sql = $this->sql->limit($sql, $this->limit, $this->offset); } // See if the query plan, rather than the // query data should be returned if ($this->explain === TRUE) { $sql = $this->sql->explain($sql); } return $sql; } } // End of abstract_query_builder.php |
- Size: 0,847 Bytes - Last Modified: 2015-11-10T10:03:56-05:00
123456789101112131415161718192021222324252627282930313233343536
- Covered by 34 test(s):
- 3738
- Covered by 34 test(s):
- 39
- Covered by 34 test(s):
- 40
- Covered by 30 test(s):
- 41
- Covered by 30 test(s):
- 4243
- Covered by 34 test(s):
- 44454647
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license * @package Query */ // -------------------------------------------------------------------------- namespace Query; /** * parent for database manipulation subclasses * * @package Query * @subpackage Drivers */ abstract class AbstractSQL implements SQLInterface { /** * Limit clause * * @param string $sql * @param int $limit * @param int|bool $offset * @return string */ public function limit($sql, $limit, $offset=FALSE) { $sql .= "\nLIMIT {$limit}"; if (is_numeric($offset)) { $sql .= " OFFSET {$offset}"; } return $sql; } } // End of abstract_sql.php |
- Size: 3,320 Bytes - Last Modified: 2015-11-10T10:04:06-05:00
123456789101112131415161718192021222324252627282930313233343536373839404142
- Covered by 7 test(s):
- 43
- Covered by 7 test(s):
- 4445464748495051525354
- Covered by 12 test(s):
- 55565758596061626364656667686970
- Covered by 3 test(s):
- 7172737475767778
- Covered by 3 test(s):
- 79
- Covered by 3 test(s):
- 8081
- Covered by 3 test(s):
- 828384
- Covered by 3 test(s):
- 85
- Covered by 3 test(s):
- 8687
- Covered by 3 test(s):
- 88
- Covered by 3 test(s):
- 89
- Covered by 3 test(s):
- 9091
- Covered by 3 test(s):
- 92
- Covered by 3 test(s):
- 939495
- Covered by 3 test(s):
- 96
- Covered by 3 test(s):
- 97
- Covered by 3 test(s):
- 9899
- Covered by 3 test(s):
- 100101102103104105106107108109110111112
- Covered by 1 test(s):
- 113114115116117118119120121122123124125126127128129130131132133134135136137138139
- Covered by 1 test(s):
-
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query; // -------------------------------------------------------------------------- /** * Abstract class defining database / table creation methods * * @package Query * @subpackage Drivers * @method string quote_ident(string $sql) * @method string quote_table(string $sql) */ abstract class AbstractUtil { /** * Reference to the current connection object */ private $conn; /** * Save a reference to the connection object for later use * * @param Driver_Interface $conn */ public function __construct(DriverInterface $conn) { $this->conn = $conn; } // -------------------------------------------------------------------------- /** * Get the driver object for the current connection * * @return Driver_Interface */ public function get_driver() { return $this->conn; } // -------------------------------------------------------------------------- /** * Convenience public function to generate sql for creating a db table * * @param string $name * @param array $fields * @param array $constraints * @param bool $if_not_exists * @return string */ public function create_table($name, $fields, array $constraints=array(), $if_not_exists=TRUE) { $exists_str = ($if_not_exists) ? ' IF NOT EXISTS ' : ' '; // Reorganize into an array indexed with column information // Eg $column_array[$colname] = array( // 'type' => ..., // 'constraint' => ..., // 'index' => ..., // ) $column_array = \array_zipper(array( 'type' => $fields, 'constraint' => $constraints )); // Join column definitions together $columns = array(); foreach($column_array as $n => $props) { $str = $this->get_driver()->quote_ident($n); $str .= (isset($props['type'])) ? " {$props['type']}" : ""; $str .= (isset($props['constraint'])) ? " {$props['constraint']}" : ""; $columns[] = $str; } // Generate the sql for the creation of the table $sql = 'CREATE TABLE'.$exists_str.$this->get_driver()->quote_table($name).' ('; $sql .= implode(', ', $columns); $sql .= ')'; return $sql; } // -------------------------------------------------------------------------- /** * Drop the selected table * * @param string $name * @return string */ public function delete_table($name) { return 'DROP TABLE IF EXISTS '.$this->get_driver()->quote_table($name); } // -------------------------------------------------------------------------- // ! Abstract Methods // -------------------------------------------------------------------------- /** * Return an SQL file with the database table structure * * @abstract * @return string */ abstract public function backup_structure(); // -------------------------------------------------------------------------- /** * Return an SQL file with the database data as insert statements * * @abstract * @return string */ abstract public function backup_data(); } // End of abstract_util.php |
- Size: 0,555 Bytes - Last Modified: 2014-08-08T12:03:58-04:00
1234567891011121314151617181920212223242526
- Covered by 1 test(s):
-
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query; /** * Generic exception for bad drivers * * @package Query * @subpackage Core */ class BadDBDriverException extends \InvalidArgumentException {} // End of BadDBDriverException.php |
- Size: 5,787 Bytes - Last Modified: 2015-11-10T10:01:22-05:00
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
- Covered by 1 test(s):
- 5657585960616263646566
- Covered by 1 test(s):
- 6768697071727374757677
- Covered by 1 test(s):
- 78798081828384858687888990
- Covered by 12 test(s):
- 9192
- Covered by 12 test(s):
- 93949596979899100101102103104105106107
- Covered by 10 test(s):
- 108
- Covered by 10 test(s):
- 109
- Covered by 3 test(s):
- 110111
- Covered by 7 test(s):
- 112113
- Covered by 2 test(s):
- 114115116117
- Covered by 5 test(s):
- 118119120121122123124125126127128129130
- Covered by 7 test(s):
- 131132
- Covered by 3 test(s):
- 133
- Covered by 3 test(s):
- 134135136
- Covered by 3 test(s):
- 137
- Covered by 3 test(s):
- 138
- Covered by 3 test(s):
- 139140141
- Covered by 3 test(s):
- 142
- Covered by 3 test(s):
- 143
- Covered by 3 test(s):
- 144
- Covered by 3 test(s):
- 145146147
- Covered by 3 test(s):
- 148149150151
- Covered by 3 test(s):
- 152
- Covered by 3 test(s):
- 153
- Covered by 2 test(s):
- 154
- Covered by 2 test(s):
- 155156157
- Covered by 1 test(s):
- 158159160
- Covered by 3 test(s):
- 161162163164165166167168169170171172173174
- Covered by 8 test(s):
- 175
- Covered by 8 test(s):
- 176
- Covered by 8 test(s):
- 177178179
- Covered by 8 test(s):
- 180
- Covered by 8 test(s):
- 181
- Covered by 4 test(s):
- 182183184185
- Covered by 4 test(s):
- 186187
- Covered by 4 test(s):
- 188
- Covered by 4 test(s):
- 189
- Covered by 3 test(s):
- 190
- Covered by 3 test(s):
- 191192193
- Covered by 4 test(s):
- 194
- Covered by 4 test(s):
- 195
- Covered by 1 test(s):
- 196
- Covered by 1 test(s):
- 197
- Covered by 3 test(s):
- 198
- Covered by 3 test(s):
- 199
- Covered by 3 test(s):
- 200
- Covered by 3 test(s):
- 201202203204205206207
- Covered by 4 test(s):
- 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query; /** * Connection manager class to manage connections for the * Query method * * @package Query * @subpackage Core */ final class ConnectionManager { /** * Map of named database connections * @var array */ private $connections = array(); /** * Class instance variable * @var Connection_Manager */ private static $instance = null; // -------------------------------------------------------------------------- /** * Private constructor to prevent multiple instances * @codeCoverageIgnore */ private function __construct() {} // -------------------------------------------------------------------------- /** * Private clone method to prevent cloning * @throws \DomainException */ public function __clone() { throw new \DomainException("Can't clone singleton"); } // -------------------------------------------------------------------------- /** * Prevent serialization of this object * @throws \DomainException */ public function __sleep() { throw new \DomainException("No serializing of singleton"); } // -------------------------------------------------------------------------- /** * Make sure serialize/deserialize doesn't work * @throws \DomainException */ public function __wakeup() { throw new \DomainException("Can't unserialize singleton"); } // -------------------------------------------------------------------------- /** * Return a connection manager instance * * @staticvar null $instance * @return Connection_Manager */ public static function get_instance() { if (self::$instance === null) self::$instance = new self(); return self::$instance; } // -------------------------------------------------------------------------- /** * Returns the connection specified by the name given * * @param string|array|object $name * @return Query_Builder * @throws \InvalidArgumentException */ public function get_connection($name = '') { // If the parameter is a string, use it as an array index if (is_scalar($name) && isset($this->connections[$name])) { return $this->connections[$name]; } elseif (empty($name) && ! empty($this->connections)) // Otherwise, return the last one { return end($this->connections); } // You should actually connect before trying to get a connection... throw new \InvalidArgumentException("The specified connection does not exist"); } // -------------------------------------------------------------------------- /** * Parse the passed parameters and return a connection * * @param \stdClass $params * @return Query_Builder */ public function connect(\stdClass $params) { list($dsn, $dbtype, $params, $options) = $this->parse_params($params); $dbtype = ucfirst($dbtype); $driver = "\\Query\\Drivers\\{$dbtype}\\Driver"; // Create the database connection $db = ( ! empty($params->user)) ? new $driver($dsn, $params->user, $params->pass, $options) : new $driver($dsn, '', '', $options); // Set the table prefix, if it exists if (isset($params->prefix)) { $db->set_table_prefix($params->prefix); } // Create Query Builder object $conn = new QueryBuilder($db, new QueryParser($db)); // Save it for later if (isset($params->alias)) { $this->connections[$params->alias] = $conn; } else { $this->connections[] = $conn; } return $conn; } // -------------------------------------------------------------------------- /** * Parses params into a dsn and option array * * @param \stdClass $params * @return array * @throws BadDBDriverException */ public function parse_params(\stdClass $params) { $params->type = strtolower($params->type); $dbtype = ($params->type !== 'postgresql') ? $params->type : 'pgsql'; $dbtype = ucfirst($dbtype); // Make sure the class exists if ( ! class_exists("\\Query\\Drivers\\{$dbtype}\\Driver")) { throw new BadDBDriverException('Database driver does not exist, or is not supported'); } // Set additional PDO options $options = array(); if (isset($params->options)) { $options = (array) $params->options; } // Create the dsn for the database to connect to if (strtolower($dbtype) === 'firebird') { $dsn = "{$params->host}:{$params->file}"; } else if(strtolower($dbtype) === 'sqlite') { $dsn = $params->file; } else { $dsn = $this->create_dsn($dbtype, $params); } return array($dsn, $dbtype, $params, $options); } // -------------------------------------------------------------------------- /** * Create the dsn from the db type and params * * @param string $dbtype * @param \stdClass $params * @return string */ private function create_dsn($dbtype, \stdClass $params) { if (strtolower($dbtype) === 'pdo_firebird') $dbtype = 'firebird'; $pairs = array(); if ( ! empty($params->database)) { $pairs[] = implode('=', array('dbname', $params->database)); } $skip = array( 'name' => 'name', 'pass' => 'pass', 'user' => 'user', 'type' => 'type', 'prefix' => 'prefix', 'options' => 'options', 'database' => 'database', 'alias' => 'alias' ); foreach($params as $key => $val) { if (( ! array_key_exists($key, $skip)) && ( ! empty($val))) { $pairs[] = implode('=', array($key, $val)); } } return strtolower($dbtype) . ':' . implode(';', $pairs); } } // End of connection_manager.php |
- Size: 5,182 Bytes - Last Modified: 2015-11-10T10:04:17-05:00
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 | <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query; /** * PDO Interface to implement for database drivers * * @package Query * @subpackage Drivers */ interface DriverInterface { /** * Constructor/Connection method * * @param string $dsn * @param string $username * @param string $password * @param array $driver_options */ public function __construct($dsn, $username=NULL, $password=NULL, array $driver_options = array()); /** * Simplifies prepared statements for database queries * * @param string $sql * @param array $data * @return \PDOStatement | FALSE * @throws \InvalidArgumentException */ public function prepare_query($sql, $data); /** * Begin a transaction * * @return bool */ public function beginTransaction(); /** * Commit a transaction * * @return bool */ public function commit(); /** * Return the current error code * * @return mixed */ public function errorCode(); /** * Return information about the current error * * @return array */ public function errorInfo(); /** * Execute an SQL statement and return the number of affected rows * * @param string $statement * @return int */ public function exec($statement); /** * Get a connection attribute for the current db driver * * @param int $attribute * @return mixed */ public function getAttribute($attribute); /** * Rollback a transaction * * @return bool */ public function rollback(); /** * Set a connection attribute * @param int $attribute * @param mixed $value * @return bool */ public function setAttribute($attribute, $value); /** * Retrieve column information for the current database table * * @param string $table * @return array */ public function get_columns($table); /** * Retrieve list of data types for the database * * @return array */ public function get_types(); /** * Retrieve indexes for the table * * @param string $table * @return array */ public function get_indexes($table); /** * Retrieve foreign keys for the table * * @param string $table * @return array */ public function get_fks($table); /** * Return list of tables for the current database * * @return array */ public function get_tables(); /** * Retrieves an array of non-user-created tables for * the connection/database * * @return array */ public function get_system_tables(); /** * Return list of dbs for the current connection, if possible * * @return array */ public function get_dbs(); /** * Return list of views for the current database * * @return array */ public function get_views(); /** * Return list of sequences for the current database, if they exist * * @return array */ public function get_sequences(); /** * Return list of functions for the current database * * @return array */ public function get_functions(); /** * Return list of stored procedures for the current database * * @return array */ public function get_procedures(); /** * Return list of triggers for the current database * * @return array */ public function get_triggers(); /** * Surrounds the string with the databases identifier escape characters * * @param string|array $ident * @return string|array */ public function quote_ident($ident); /** * Quote database table name, and set prefix * * @param string|array $table * @return string|array */ public function quote_table($table); /** * Create and execute a prepared statement with the provided parameters * * @param string $sql * @param array $params * @return \PDOStatement */ public function prepare_execute($sql, $params); /** * Get the SQL class for the current driver * * @return SQL_Interface */ public function get_sql(); /** * Get the Util class for the current driver * * @return Abstract_Util */ public function get_util(); /** * Method to simplify retrieving db results for meta-data queries * * @param string|array|null $query * @param bool $filtered_index * @return array */ public function driver_query($query, $filtered_index=TRUE); /** * Returns number of rows affected by an INSERT, UPDATE, DELETE type query * * @return int */ public function affected_rows(); /** * Return the number of rows returned for a SELECT query * @see http://us3.php.net/manual/en/pdostatement.rowcount.php#87110 * * @return int */ public function num_rows(); /** * Prefixes a table if it is not already prefixed * * @param string $table * @return string */ public function prefix_table($table); /** * Create sql for batch insert * * @param string $table * @param array $data * @return array */ public function insert_batch($table, $data=array()); } // End of driver_interface.php |
- Size: 8,786 Bytes - Last Modified: 2015-11-10T09:58:30-05:00
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
- Covered by 1 test(s):
- 83
- Covered by 1 test(s):
- 84
- Covered by 1 test(s):
- 8586
- Covered by 1 test(s):
- 87
- Covered by 1 test(s):
- 888990
- Covered by 1 test(s):
- 919293949596
- Covered by 1 test(s):
- 97
- Covered by 1 test(s):
- 9899100101102103104105106107108109110111112113114115116117118119
- Covered by 1 test(s):
- 120121122123124125126127128129130131132133
- Covered by 1 test(s):
- 134135136137138139140141142143144145146
- Covered by 1 test(s):
- 147148149150151152153154155156157158
- Covered by 1 test(s):
- 159160161162163164165166167168169170171
- Covered by 1 test(s):
- 172173174175176177178179180181182183184185186
- Covered by 55 test(s):
- 187188
- Covered by 55 test(s):
- 189
- Covered by 55 test(s):
- 190
- Covered by 55 test(s):
- 191192193
- Covered by 55 test(s):
- 194
- Covered by 55 test(s):
- 195196
- Covered by 55 test(s):
- 197198
- Covered by 55 test(s):
- 199200201202203204205206207208209210211212213
- Covered by 37 test(s):
- 214215216
- Covered by 37 test(s):
- 217218
- Covered by 37 test(s):
- 219220
- Covered by 37 test(s):
- 221222223224225226227228229230231232
- Covered by 3 test(s):
- 233234235236237238239240241242243244
- Covered by 1 test(s):
- 245
- Covered by 1 test(s):
- 246
- Covered by 1 test(s):
- 247248249250251252253254255256257258
- Covered by 2 test(s):
- 259
- Covered by 2 test(s):
- 260
- Covered by 2 test(s):
- 261262263264265266267268269270271272273
- Covered by 1 test(s):
- 274275276277278279280281282283284285286287
- Covered by 36 test(s):
- 288289290
- Covered by 36 test(s):
- 291292
- Covered by 36 test(s):
- 293294295296297298299300301302303304305306
- Covered by 17 test(s):
- 307
- Covered by 17 test(s):
- 308
- Covered by 2 test(s):
- 309310311
- Covered by 17 test(s):
- 312313314315316317318319320321322323
- Covered by 2 test(s):
- 324
- Covered by 2 test(s):
- 325326
- Covered by 2 test(s):
- 327328329330331332333334335336337338
- Covered by 2 test(s):
- 339340341342343344345346347348349350351352353354
- Covered by 1 test(s):
- 355356357358359360361362363364365366367368369
- Covered by 1 test(s):
- 370371372
- Covered by 1 test(s):
- 373374
- Covered by 1 test(s):
- 375
- Covered by 1 test(s):
- 376377
- Covered by 1 test(s):
- 378
- Covered by 1 test(s):
- 379
- Covered by 1 test(s):
- 380381
- Covered by 1 test(s):
- 382383384
- Covered by 1 test(s):
- 385386387
- Covered by 1 test(s):
- 388
- Covered by 1 test(s):
- 389390391
- Covered by 1 test(s):
- 392393394395396
- Covered by 1 test(s):
- 397398399
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query\Drivers\Firebird; /** * Firebird Database class * * PDO-firebird isn't stable, so this is a wrapper of the fbird_ public functions. * * @package Query * @subpackage Drivers */ class Driver extends \Query\AbstractDriver { /** * Reference to the last query executed * * @var object */ protected $statement = NULL; /** * Reference to the resource returned by * the last query executed * * @var resource */ protected $statement_link = NULL; /** * Reference to the current transaction * * @var resource */ protected $trans = NULL; /** * Reference to the connection resource * * @var resource */ protected $conn = NULL; /** * Reference to the service resource * * @var resource */ protected $service = NULL; /** * Firebird doesn't have the truncate keyword * * @var bool */ protected $has_truncate = FALSE; /** * Open the link to the database * * @param string $dbpath * @param string $user * @param string $pass * @param array $options * @throws \PDOException */ public function __construct($dbpath, $user='SYSDBA', $pass='masterkey', array $options = array()) { $connect_function = (isset($options[\PDO::ATTR_PERSISTENT]) && $options[\PDO::ATTR_PERSISTENT] == TRUE) ? '\\fbird_pconnect' : '\\fbird_connect'; $this->conn = $connect_function($dbpath, $user, $pass, 'utf-8', 0); $this->service = \fbird_service_attach('localhost', $user, $pass); // Throw an exception to make this match other pdo classes if ( ! \is_resource($this->conn)) throw new \PDOException(\fbird_errmsg(), \fbird_errcode(), NULL); // Load these classes here because this // driver does not call the constructor // of DB_PDO, which defines these // class variables for the other drivers $this->_load_sub_classes(); } // -------------------------------------------------------------------------- /** * Cleanup some loose ends * @codeCoverageIgnore */ public function __destruct() { \fbird_service_detach($this->service); } // -------------------------------------------------------------------------- /** * Return service handle * * @return resource */ public function get_service() { return $this->service; } // -------------------------------------------------------------------------- /** * Execute an sql statement and return number of affected rows * * @param string $sql * @return int */ public function exec($sql) { return NULL; } // -------------------------------------------------------------------------- /** * Implement for compatibility with PDO * * @param int $attribute * @return mixed */ public function getAttribute($attribute) { return NULL; } // -------------------------------------------------------------------------- /** * Return whether the current statement is in a transaction * * @return bool */ public function inTransaction() { return ! is_null($this->trans); } // -------------------------------------------------------------------------- /** * Returns the last value of the specified generator * * @param string $name * @return mixed */ public function lastInsertId($name = NULL) { return \fbird_gen_id($name, 0, $this->conn); } // -------------------------------------------------------------------------- /** * Wrapper public function to better match PDO * * @param string $sql * @return Result * @throws PDOException */ public function query($sql = '') { if (empty($sql)) throw new \PDOException("Query method requires an sql query!", 0, NULL); $this->statement_link = (isset($this->trans)) ? \fbird_query($this->trans, $sql) : \fbird_query($this->conn, $sql); // Throw the error as a exception $err_string = \fbird_errmsg() . "Last query:" . $this->get_last_query(); if ($this->statement_link === FALSE) throw new \PDOException($err_string, \fbird_errcode(), NULL); $this->statement = new Result($this->statement_link, $this); return $this->statement; } // -------------------------------------------------------------------------- /** * Emulate PDO prepare * * @param string $query * @param array $options * @return Result * @throws \PDOException */ public function prepare($query, $options=array()) { $this->statement_link = \fbird_prepare($this->conn, $query); // Throw the error as an exception if ($this->statement_link === FALSE) throw new \PDOException(\fbird_errmsg(), \fbird_errcode(), NULL); $this->statement = new Result($this->statement_link, $this); return $this->statement; } // -------------------------------------------------------------------------- /** * Start a database transaction * * @return boolean|null */ public function beginTransaction() { return (($this->trans = \fbird_trans($this->conn)) !== NULL) ? TRUE : NULL; } // -------------------------------------------------------------------------- /** * Commit a database transaction * * @return bool */ public function commit() { $res = \fbird_commit($this->trans); $this->trans = NULL; return $res; } // -------------------------------------------------------------------------- /** * Rollback a transaction * * @return bool */ public function rollBack() { $res = \fbird_rollback($this->trans); $this->trans = NULL; return $res; } // -------------------------------------------------------------------------- /** * Set a connection attribute * @param int $attribute * @param mixed $value * @return bool */ public function setAttribute($attribute, $value) { return FALSE; } // -------------------------------------------------------------------------- /** * Prepare and execute a query * * @param string $sql * @param array $args * @return Result */ public function prepare_execute($sql, $args) { $query = $this->prepare($sql); // Set the statement in the class variable for easy later access $this->statement_link =& $query; return $query->execute($args); } // -------------------------------------------------------------------------- /** * Method to emulate PDO->quote * * @param string $str * @param int $param_type * @return string */ public function quote($str, $param_type = \PDO::PARAM_STR) { if(is_numeric($str)) { return $str; } return "'".str_replace("'", "''", $str)."'"; } // -------------------------------------------------------------------------- /** * Method to emulate PDO->errorInfo / PDOStatement->errorInfo * * @return array */ public function errorInfo() { $code = \fbird_errcode(); $msg = \fbird_errmsg(); return array(0, $code, $msg); } // -------------------------------------------------------------------------- /** * Method to emulate PDO->errorCode * * @return array */ public function errorCode() { return \fbird_errcode(); } // -------------------------------------------------------------------------- /** * Bind a prepared query with arguments for executing * * @param string $sql * @param array $params * @return NULL */ public function prepare_query($sql, $params) { // You can't bind query statements before execution with // the firebird database return NULL; } // -------------------------------------------------------------------------- /** * Create sql for batch insert * * @param string $table * @param array $data * @return array */ public function insert_batch($table, $data=array()) { // Each member of the data array needs to be an array if ( ! is_array(current($data))) return NULL; // Start the block of sql statements $sql = "EXECUTE BLOCK AS BEGIN\n"; $table = $this->quote_table($table); $fields = \array_keys(\current($data)); $insert_template = "INSERT INTO {$table} (" . implode(',', $this->quote_ident($fields)) . ") VALUES ("; foreach($data as $item) { // Quote string values $vals = array_map(array($this, 'quote'), $item); // Add the values in the sql $sql .= $insert_template . implode(', ', $vals) . ");\n"; } // End the block of SQL statements $sql .= "END"; // Return a null array value so the query is run as it is, // not as a prepared statement, because a prepared statement // doesn't work for this type of query in Firebird. return array($sql, NULL); } } // End of firebird_driver.php |
- Size: 6,247 Bytes - Last Modified: 2015-07-30T15:42:19-04:00
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
- Covered by 90 test(s):
- 65
- Covered by 90 test(s):
- 66
- Covered by 90 test(s):
- 67
- Covered by 90 test(s):
- 68
- Covered by 90 test(s):
- 6970717273
- Covered by 90 test(s):
- 74
- Covered by 90 test(s):
- 75
- Covered by 81 test(s):
- 7677
- Covered by 72 test(s):
- 78
- Covered by 72 test(s):
- 798081
- Covered by 81 test(s):
- 82
- Covered by 81 test(s):
- 83
- Covered by 90 test(s):
- 84858687888990919293949596979899
- Covered by 1 test(s):
- 100101102103104105106107108109110111112113114115116
- Covered by 1 test(s):
- 117118119120121122123124125126127128129130131
- Covered by 1 test(s):
- 132133134135136137138139140141142143144145
- Covered by 37 test(s):
- 146147148149150
- Covered by 37 test(s):
- 151152
- Covered by 37 test(s):
- 153154155156157158159160161162163164165166167168
- Covered by 38 test(s):
- 169
- Covered by 38 test(s):
- 170
- Covered by 4 test(s):
- 171172173174
- Covered by 38 test(s):
- 175176177
- Covered by 38 test(s):
- 178
- Covered by 38 test(s):
- 179
- Covered by 37 test(s):
- 180181182183184
- Covered by 38 test(s):
- 185
- Covered by 1 test(s):
- 186
- Covered by 1 test(s):
- 187188
- Covered by 38 test(s):
- 189
- Covered by 34 test(s):
- 190
- Covered by 34 test(s):
- 191192
- Covered by 10 test(s):
- 193
- Covered by 10 test(s):
- 194
- Covered by 10 test(s):
- 195
- Covered by 10 test(s):
- 196197
- Covered by 38 test(s):
- 198199200201202203204205206207208209210211212
- Covered by 37 test(s):
- 213214
- Covered by 37 test(s):
- 215216
- Covered by 37 test(s):
- 217
- Covered by 37 test(s):
- 218219
- Covered by 37 test(s):
- 220221
- Covered by 37 test(s):
- 222223224225226227228229230231232233234
- Covered by 2 test(s):
- 235
- Covered by 2 test(s):
- 236237238239240241242243244245246247248249
- Covered by 1 test(s):
- 250251252253254255256257258259260261
- Covered by 2 test(s):
- 262263264265266267268269270271272273
- Covered by 1 test(s):
- 274275276277278279280281282283284285
- Covered by 1 test(s):
- 286287288
- Covered by 1 test(s):
-
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query\Drivers\Firebird; /** * Firebird result class to emulate PDOStatement Class - only implements * data-fetching methods * * @package Query * @subpackage Drivers */ class Result extends \PDOStatement { /** * Reference to fbird resource * * @var resource */ private $statement; /** * Current row in result array * * @var int */ private $row; /** * Data pulled from query * * @param mixed */ private $result = array(); /** * Reference to the db drive to de-duplicate error functions * * @var \Query\Drivers\Firebird\Driver */ private $db; /** * Create the object by passing the resource for * the query * * @param resource $link * @param Driver|null $db */ public function __construct($link, Driver $db = NULL) { if ( ! is_null($db)) $this->db = $db; $this->statement = $link; $this->setFetchMode(\PDO::FETCH_ASSOC); $this->row = -1; $this->result = array(); // Create the result array, so that we can get row counts // Check the resource type, because prepared statements are "interbase query" // but we only want "interbase result" types when attempting to fetch data if (\is_resource($link) && \get_resource_type($link) === "interbase result") { while($row = \fbird_fetch_assoc($link, \IBASE_FETCH_BLOBS)) { $this->result[] = $row; } // Free the result resource \fbird_free_result($link); } } // -------------------------------------------------------------------------- /** * Invalidate method for data consistency * * @param mixed $column * @param mixed $param * @param int $type * @param mixed $maxlen * @param array $driverdata * @return NULL */ public function bindColumn($column, &$param, $type=NULL, $maxlen=NULL, $driverdata=NULL) { return NULL; } // -------------------------------------------------------------------------- /** * Invalidate method for data consistency * * @param mixed $parameter * @param mixed $variable * @param int $data_type * @param mixed $maxlen * @param array $driverdata * @return NULL */ public function bindParam($parameter, &$variable, $data_type=NULL, $maxlen=NULL, $driverdata=NULL) { return NULL; } // -------------------------------------------------------------------------- /** * Invalidate method for data consistency * * @param mixed $parameter * @param mixed $variable * @param int $data_type * @return NULL */ public function bindValue($parameter, $variable, $data_type=NULL) { return NULL; } // -------------------------------------------------------------------------- /** * Run a prepared statement query * * @param array $args * @return Result */ public function execute($args = NULL) { //Add the prepared statement as the first parameter \array_unshift($args, $this->statement); // Let php do all the hard stuff in converting // the array of arguments into a list of arguments // Then pass the resource to the constructor $this->__construct(\call_user_func_array('fbird_execute', $args)); return $this; } // -------------------------------------------------------------------------- /** * Emulate PDO fetch public function * * @param int $fetch_style * @param mixed $cursor_orientation * @param mixed $cursor_offset * @return mixed */ public function fetch($fetch_style=\PDO::FETCH_ASSOC, $cursor_orientation = \PDO::FETCH_ORI_NEXT, $cursor_offset=NULL) { // If there is no result, continue if (empty($this->result)) { return NULL; } // Keep track of the current row being fetched ++$this->row; // return NULL if the next row doesn't exist if ( ! isset($this->result[$this->row])) { return NULL; } switch($fetch_style) { case \PDO::FETCH_OBJ: $row = (object) $this->result[$this->row]; break; case \PDO::FETCH_NUM: $row = \array_values($this->result[$this->row]); break; default: $row = $this->result[$this->row]; break; } return $row; } // -------------------------------------------------------------------------- /** * Emulate PDO fetchAll public function * * @param int $fetch_style * @param mixed $statement * @param mixed $ctor_args * @return mixed */ public function fetchAll($fetch_style=\PDO::FETCH_ASSOC, $statement=NULL, $ctor_args=NULL) { $all = array(); while($row = $this->fetch($fetch_style, $statement)) { $all[] = $row; } $this->result = $all; return $all; } // -------------------------------------------------------------------------- /** * Emulate PDOStatement::fetchColumn * * @param int $column_num * @return mixed */ public function fetchColumn($column_num=0) { $row = $this->fetch(\PDO::FETCH_NUM); return $row[$column_num]; } // -------------------------------------------------------------------------- /** * Emulate PDOStatement::fetchObject, but only for the default use * * @param string $class_name * @param array $ctor_args * @return stdClass */ public function fetchObject($class_name='stdClass', $ctor_args=array()) { return $this->fetch(\PDO::FETCH_OBJ); } // -------------------------------------------------------------------------- /** * Return the number of rows affected by the previous query * * @return int */ public function rowCount() { return \fbird_affected_rows(); } // -------------------------------------------------------------------------- /** * Method to emulate PDOStatement->errorCode * * @return string */ public function errorCode() { return $this->db->errorCode(); } // -------------------------------------------------------------------------- /** * Method to emulate PDO->errorInfo / PDOStatement->errorInfo * * @return array */ public function errorInfo() { return $this->db->errorInfo(); } } // End of firebird_result.php |
- Size: 7,274 Bytes - Last Modified: 2015-11-10T10:04:50-05:00
12345678910111213141516171819202122232425262728293031323334353637
- Covered by 17 test(s):
- 3839
- Covered by 17 test(s):
- 4041
- Covered by 17 test(s):
- 42
- Covered by 17 test(s):
- 43
- Covered by 15 test(s):
- 44
- Covered by 15 test(s):
- 4546
- Covered by 17 test(s):
- 4748
- Covered by 17 test(s):
- 49505152535455565758596061
- Covered by 1 test(s):
- 626364656667686970717273
- Covered by 1 test(s):
- 74757677787980818283848586
- Covered by 1 test(s):
- 87888990919293949596979899100101102103104
- Covered by 32 test(s):
- 105106107108109110111112113114115116117118119120121
- Covered by 1 test(s):
- 122123124125126127128129130131132133134135136
- Covered by 1 test(s):
- 137138139140141142143144145146147148149150151
- Covered by 1 test(s):
- 152153154155156157158159160161162163
- Covered by 1 test(s):
- 164165166167168169170171172173174175176177178179180181182183184185186187188189190
- Covered by 1 test(s):
- 191192193194195196197198199200201202203204205206207
- Covered by 1 test(s):
- 208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
- Covered by 1 test(s):
- 253
- Covered by 1 test(s):
- 254
- Covered by 1 test(s):
- 255256257258259260261262263264265266267268269270
- Covered by 2 test(s):
- 271272273274275276277278279280281282283284285286287288289290291292293294295296297298
- Covered by 1 test(s):
- 299
- Covered by 1 test(s):
- 300301302303304305306307308309310311312313314315
- Covered by 1 test(s):
- 316
- Covered by 1 test(s):
- 317318319
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query\Drivers\Firebird; /** * Firebird Specific SQL * * @package Query * @subpackage Drivers */ class SQL extends \Query\AbstractSQL { /** * Limit clause * * @param string $sql * @param int $limit * @param int|bool $offset * @return string */ public function limit($sql, $limit, $offset=FALSE) { // Keep the current sql string safe for a moment $orig_sql = $sql; $sql = 'FIRST '. (int) $limit; if ($offset > 0) { $sql .= ' SKIP '. (int) $offset; } $sql = preg_replace("`SELECT`i", "SELECT {$sql}", $orig_sql); return $sql; } // -------------------------------------------------------------------------- /** * Get the query plan for the sql query * * @param string $sql * @return string */ public function explain($sql) { return $sql; } // -------------------------------------------------------------------------- /** * Random ordering keyword * * @return string */ public function random() { return NULL; } // -------------------------------------------------------------------------- /** * Returns sql to list other databases * * @return NULL */ public function db_list() { return NULL; } // -------------------------------------------------------------------------- /** * Returns sql to list tables * * @return string */ public function table_list() { return <<<SQL SELECT TRIM("RDB\$RELATION_NAME") FROM "RDB\$RELATIONS" WHERE "RDB\$SYSTEM_FLAG"=0 AND "RDB\$VIEW_BLR" IS NULL ORDER BY "RDB\$RELATION_NAME" ASC SQL; } // -------------------------------------------------------------------------- /** * Returns sql to list system tables * * @return string */ public function system_table_list() { return <<<SQL SELECT TRIM("RDB\$RELATION_NAME") FROM "RDB\$RELATIONS" WHERE "RDB\$SYSTEM_FLAG"=1 ORDER BY "RDB\$RELATION_NAME" ASC SQL; } // -------------------------------------------------------------------------- /** * Returns sql to list views * * @return string */ public function view_list() { return <<<SQL SELECT DISTINCT TRIM("RDB\$VIEW_NAME") FROM "RDB\$VIEW_RELATIONS" SQL; } // -------------------------------------------------------------------------- /** * Returns sql to list triggers * * @return string */ public function trigger_list() { return <<<SQL SELECT * FROM "RDB\$FUNCTIONS" WHERE "RDB\$SYSTEM_FLAG" = 0 SQL; } // -------------------------------------------------------------------------- /** * Return sql to list functions * * @return string */ public function function_list() { return 'SELECT * FROM "RDB$FUNCTIONS"'; } // -------------------------------------------------------------------------- /** * Return sql to list stored procedures * * @return string */ public function procedure_list() { return <<<SQL SELECT "RDB\$PROCEDURE_NAME", "RDB\$PROCEDURE_ID", "RDB\$PROCEDURE_INPUTS", "RDB\$PROCEDURE_OUTPUTS", "RDB\$DESCRIPTION", "RDB\$PROCEDURE_SOURCE", "RDB\$SECURITY_CLASS", "RDB\$OWNER_NAME", "RDB\$RUNTIME", "RDB\$SYSTEM_FLAG", "RDB\$PROCEDURE_TYPE", "RDB\$VALID_BLR" FROM "RDB\$PROCEDURES" ORDER BY "RDB\$PROCEDURE_NAME" ASC SQL; } // -------------------------------------------------------------------------- /** * Return sql to list sequences * * @return string */ public function sequence_list() { return <<<SQL SELECT TRIM("RDB\$GENERATOR_NAME") FROM "RDB\$GENERATORS" WHERE "RDB\$SYSTEM_FLAG" = 0 SQL; } // -------------------------------------------------------------------------- /** * Return sql to list columns of the specified table * * @param string $table * @return string */ public function column_list($table) { return <<<SQL SELECT r.RDB\$FIELD_NAME AS field_name, r.RDB\$DESCRIPTION AS field_description, r.RDB\$DEFAULT_VALUE AS field_default_value, r.RDB\$NULL_FLAG AS field_not_null_constraint, f.RDB\$FIELD_LENGTH AS field_length, f.RDB\$FIELD_PRECISION AS field_precision, f.RDB\$FIELD_SCALE AS field_scale, CASE f.RDB\$FIELD_TYPE WHEN 261 THEN 'BLOB' WHEN 14 THEN 'CHAR' WHEN 40 THEN 'CSTRING' WHEN 11 THEN 'D_FLOAT' WHEN 27 THEN 'DOUBLE' WHEN 10 THEN 'FLOAT' WHEN 16 THEN 'INT64' WHEN 8 THEN 'INTEGER' WHEN 9 THEN 'QUAD' WHEN 7 THEN 'SMALLINT' WHEN 12 THEN 'DATE' WHEN 13 THEN 'TIME' WHEN 35 THEN 'TIMESTAMP' WHEN 37 THEN 'VARCHAR' ELSE 'UNKNOWN' END AS field_type, f.RDB\$FIELD_SUB_TYPE AS field_subtype, coll.RDB\$COLLATION_NAME AS field_collation, cset.RDB\$CHARACTER_SET_NAME AS field_charset FROM RDB\$RELATION_FIELDS r LEFT JOIN RDB\$FIELDS f ON r.RDB\$FIELD_SOURCE = f.RDB\$FIELD_NAME LEFT JOIN RDB\$COLLATIONS coll ON f.RDB\$COLLATION_ID = coll.RDB\$COLLATION_ID LEFT JOIN RDB\$CHARACTER_SETS cset ON f.RDB\$CHARACTER_SET_ID = cset.RDB\$CHARACTER_SET_ID WHERE r.RDB\$RELATION_NAME='{$table}' ORDER BY r.RDB\$FIELD_POSITION SQL; } // -------------------------------------------------------------------------- /** * SQL to show list of field types * * @return string */ public function type_list() { return <<<SQL SELECT "RDB\$TYPE_NAME", "RDB\$FIELD_NAME" FROM "RDB\$TYPES" WHERE "RDB\$FIELD_NAME" IN ('RDB\$FIELD_TYPE', 'RDB\$FIELD_SUB_TYPE') ORDER BY "RDB\$FIELD_NAME" DESC, "RDB\$TYPE_NAME" ASC SQL; } // -------------------------------------------------------------------------- /** * Get the list of foreign keys for the current * table * * @param string $table * @return string */ public function fk_list($table) { return <<<SQL SELECT DISTINCT TRIM(d1.RDB\$FIELD_NAME) AS "child_column", TRIM(d2.RDB\$DEPENDED_ON_NAME) AS "parent_table", TRIM(d2.RDB\$FIELD_NAME) AS "parent_column", TRIM(refc.RDB\$UPDATE_RULE) AS "update", TRIM(refc.RDB\$DELETE_RULE) AS "delete" FROM RDB\$RELATION_CONSTRAINTS AS rc LEFT JOIN RDB\$REF_CONSTRAINTS refc ON rc.RDB\$CONSTRAINT_NAME = refc.RDB\$CONSTRAINT_NAME LEFT JOIN RDB\$DEPENDENCIES d1 ON d1.RDB\$DEPENDED_ON_NAME = rc.RDB\$RELATION_NAME LEFT JOIN RDB\$DEPENDENCIES d2 ON d1.RDB\$DEPENDENT_NAME = d2.RDB\$DEPENDENT_NAME WHERE rc.RDB\$CONSTRAINT_TYPE = 'FOREIGN KEY' AND d1.RDB\$DEPENDED_ON_NAME <> d2.RDB\$DEPENDED_ON_NAME AND d1.RDB\$FIELD_NAME <> d2.RDB\$FIELD_NAME AND rc.RDB\$RELATION_NAME = '{$table}' -- table name SQL; } // -------------------------------------------------------------------------- /** * Get the list of indexes for the current table * * @param string $table * @return array */ public function index_list($table) { return <<<SQL SELECT "RDB\$INDEX_NAME", "RDB\$UNIQUE_FLAG", "RDB\$FOREIGN_KEY" FROM "RDB\$INDICES" WHERE "RDB\$RELATION_NAME"='{$table}' SQL; } } //End of firebird_sql.php |
- Size: 3,272 Bytes - Last Modified: 2015-11-10T10:04:57-05:00
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
- Covered by 1 test(s):
- 5051525354555657585960616263
- Covered by 1 test(s):
- 64
- Covered by 1 test(s):
- 656667686970717273747576777879
- Covered by 1 test(s):
- 80
- Covered by 1 test(s):
- 81
- Covered by 1 test(s):
- 8283848586
- Covered by 1 test(s):
- 87
- Covered by 1 test(s):
- 88
- Covered by 1 test(s):
- 89
- Covered by 1 test(s):
- 9091
- Covered by 1 test(s):
- 929394
- Covered by 1 test(s):
- 9596
- Covered by 1 test(s):
- 97
- Covered by 1 test(s):
- 98
- Covered by 1 test(s):
- 99100101
- Covered by 1 test(s):
- 102103104
- Covered by 1 test(s):
- 105106
- Covered by 1 test(s):
- 107108109
- Covered by 1 test(s):
- 110111
- Covered by 1 test(s):
- 112113114
- Covered by 1 test(s):
- 115
- Covered by 1 test(s):
- 116
- Covered by 1 test(s):
- 117
- Covered by 1 test(s):
- 118
- Covered by 1 test(s):
- 119120
- Covered by 1 test(s):
- 121122
- Covered by 1 test(s):
- 123124
- Covered by 1 test(s):
- 125
- Covered by 1 test(s):
- 126127
- Covered by 1 test(s):
- 128
- Covered by 1 test(s):
- 129130
- Covered by 1 test(s):
- 131132133
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query\Drivers\Firebird; /** * Firebird-specific backup, import and creation methods * * @package Query * @subpackage Drivers */ class Util extends \Query\AbstractUtil { /** * Convenience public function to generate sql for creating a db table * * @deprecated Use the table builder class instead * @param string $name * @param array $fields * @param array $constraints * @param bool $if_not_exists * @return string */ public function create_table($name, $fields, array $constraints=array(), $if_not_exists=FALSE) { return parent::create_table($name, $fields, $constraints, FALSE); } /** * Drop the selected table * * @param string $name * @return string */ public function delete_table($name) { return 'DROP TABLE '.$this->get_driver()->quote_table($name); } // -------------------------------------------------------------------------- /** * Create an SQL backup file for the current database's structure * * @param string $db_path * @param string $new_file * @return string */ public function backup_structure() { list($db_path, $new_file) = func_get_args(); return ibase_backup($this->get_driver()->get_service(), $db_path, $new_file, \IBASE_BKP_METADATA_ONLY); } // -------------------------------------------------------------------------- /** * Create an SQL backup file for the current database's data * * @param array $exclude * @param bool $system_tables * @return string */ public function backup_data($exclude=array(), $system_tables=FALSE) { // Determine which tables to use $tables = $this->get_driver()->get_tables(); if($system_tables == TRUE) { $tables = array_merge($tables, $this->get_driver()->get_system_tables()); } // Filter out the tables you don't want if( ! empty($exclude)) { $tables = array_diff($tables, $exclude); } $output_sql = ''; // Get the data for each object foreach($tables as $t) { $sql = 'SELECT * FROM "'.trim($t).'"'; $res = $this->get_driver()->query($sql); $obj_res = $res->fetchAll(\PDO::FETCH_ASSOC); // Don't add to the file if the table is empty if (count($obj_res) < 1) continue; // Nab the column names by getting the keys of the first row $columns = @array_keys($obj_res[0]); $insert_rows = array(); // Create the insert statements foreach($obj_res as $row) { $row = array_values($row); // Quote values as needed by type if(stripos($t, 'RDB$') === FALSE) { $row = array_map(array($this->get_driver(), 'quote'), $row); $row = array_map('trim', $row); } $row_string = 'INSERT INTO "'.trim($t).'" ("'.implode('","', $columns).'") VALUES ('.implode(',', $row).');'; $row = NULL; $insert_rows[] = $row_string; } $output_sql .= "\n\nSET TRANSACTION;\n".implode("\n", $insert_rows)."\nCOMMIT;"; } return $output_sql; } } // End of firebird_util.php |
- Size: 1,249 Bytes - Last Modified: 2015-11-10T09:58:22-05:00
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 | <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query\Drivers\Mysql; /** * MySQL specific class * * @package Query * @subpackage Drivers */ class Driver extends \Query\AbstractDriver { /** * Set the backtick as the MySQL escape character * * @var string */ protected $escape_char = '`'; /** * Connect to MySQL Database * * @codeCoverageIgnore * @param string $dsn * @param string $username * @param string $password * @param array $options */ public function __construct($dsn, $username=null, $password=null, array $options=array()) { // Set the charset to UTF-8 if (defined('\\PDO::MYSQL_ATTR_INIT_COMMAND')) { $options = array_merge($options, array( \PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES UTF-8 COLLATE 'UTF-8'", )); } if (strpos($dsn, 'mysql') === FALSE) $dsn = 'mysql:'.$dsn; parent::__construct($dsn, $username, $password, $options); } } //End of mysql_driver.php |
- Size: 4,924 Bytes - Last Modified: 2015-11-10T10:05:02-05:00
123456789101112131415161718192021222324252627282930313233343536
- Covered by 17 test(s):
- 37
- Covered by 17 test(s):
- 38
- Covered by 2 test(s):
- 394041
- Covered by 15 test(s):
- 42434445464748495051525354
- Covered by 1 test(s):
- 555657585960616263646566
- Covered by 1 test(s):
- 676869707172737475767778
- Covered by 1 test(s):
- 79808182838485868788899091
- Covered by 3 test(s):
- 9293
- Covered by 3 test(s):
- 949596979899100101102103104105106
- Covered by 1 test(s):
- 107108109110111112113114115116117118
- Covered by 1 test(s):
- 119120121122123124125126127128129130
- Covered by 1 test(s):
- 131132133134135136137138139140141142
- Covered by 1 test(s):
- 143144145146147148149150151152153154
- Covered by 1 test(s):
- 155156157158159160161162163164165166
- Covered by 1 test(s):
- 167168169170171172173174175176177178
- Covered by 1 test(s):
- 179180181182183184185186187188189190191
- Covered by 1 test(s):
- 192193194195196197198199200201202203204205206207208209210211212213214215216217
- Covered by 1 test(s):
- 218
- Covered by 1 test(s):
- 219220221222223224225226227228229230231
- Covered by 1 test(s):
- 232233234
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query\Drivers\Mysql; /** * MySQL specifc SQL * * @package Query * @subpackage Drivers */ class SQL extends \Query\AbstractSQL { /** * Limit clause * * @param string $sql * @param int $limit * @param int $offset * @return string */ public function limit($sql, $limit, $offset=FALSE) { if ( ! is_numeric($offset)) { return $sql." LIMIT {$limit}"; } return $sql." LIMIT {$offset}, {$limit}"; } // -------------------------------------------------------------------------- /** * Get the query plan for the sql query * * @param string $sql * @return string */ public function explain($sql) { return "EXPLAIN EXTENDED {$sql}"; } // -------------------------------------------------------------------------- /** * Random ordering keyword * * @return string */ public function random() { return ' RAND() DESC'; } // -------------------------------------------------------------------------- /** * Returns sql to list other databases * * @return string */ public function db_list() { return "SHOW DATABASES WHERE `Database` NOT IN ('information_schema','mysql')"; } // -------------------------------------------------------------------------- /** * Returns sql to list tables * * @param string $database * @return string */ public function table_list($database='') { if ( ! empty($database)) return "SHOW TABLES FROM `{$database}`"; return 'SHOW TABLES'; } // -------------------------------------------------------------------------- /** * Overridden in MySQL class * * @return string */ public function system_table_list() { return 'SELECT `TABLE_NAME` FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA`=\'information_schema\''; } // -------------------------------------------------------------------------- /** * Returns sql to list views * * @return string */ public function view_list() { return 'SELECT `table_name` FROM `information_schema`.`views`'; } // -------------------------------------------------------------------------- /** * Returns sql to list triggers * * @return string */ public function trigger_list() { return 'SHOW TRIGGERS'; } // -------------------------------------------------------------------------- /** * Return sql to list functions * * @return string */ public function function_list() { return 'SHOW FUNCTION STATUS'; } // -------------------------------------------------------------------------- /** * Return sql to list stored procedures * * @return string */ public function procedure_list() { return 'SHOW PROCEDURE STATUS'; } // -------------------------------------------------------------------------- /** * Return sql to list sequences * * @return NULL */ public function sequence_list() { return NULL; } // -------------------------------------------------------------------------- /** * SQL to show list of field types * * @return string */ public function type_list() { return "SELECT DISTINCT `DATA_TYPE` FROM `information_schema`.`COLUMNS`"; } // -------------------------------------------------------------------------- /** * SQL to show infromation about columns in a table * * @param string $table * @return string */ public function column_list($table) { return "SHOW FULL COLUMNS FROM {$table}"; } // -------------------------------------------------------------------------- /** * Get the list of foreign keys for the current * table * * @param string $table * @return string */ public function fk_list($table) { return <<<SQL SELECT DISTINCT `kcu`.`COLUMN_NAME` as `child_column`, `kcu`.`REFERENCED_TABLE_NAME` as `parent_table`, `kcu`.`REFERENCED_COLUMN_NAME` as `parent_column`, `rc`.`UPDATE_RULE` AS `update`, `rc`.`DELETE_RULE` AS `delete` FROM `INFORMATION_SCHEMA`.`TABLE_CONSTRAINTS` `tc` INNER JOIN `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu` ON `kcu`.`CONSTRAINT_NAME`=`tc`.`CONSTRAINT_NAME` INNER JOIN `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS` `rc` ON `rc`.`CONSTRAINT_NAME`=`tc`.`CONSTRAINT_NAME` WHERE `tc`.`CONSTRAINT_TYPE`='FOREIGN KEY' AND `tc`.`TABLE_NAME`='{$table}' SQL; } // -------------------------------------------------------------------------- /** * Get the list of indexes for the current table * * @param string $table * @return array */ public function index_list($table) { return "SHOW INDEX IN {$table}"; } } //End of mysql_sql.php |
- Size: 2,600 Bytes - Last Modified: 2015-11-10T10:05:07-05:00
123456789101112131415161718192021222324252627282930313233
- Covered by 1 test(s):
- 343536
- Covered by 1 test(s):
- 3738
- Covered by 1 test(s):
- 394041
- Covered by 1 test(s):
- 424344
- Covered by 1 test(s):
- 4546
- Covered by 1 test(s):
- 4748
- Covered by 1 test(s):
- 49
- Covered by 1 test(s):
- 5051
- Covered by 1 test(s):
- 525354
- Covered by 1 test(s):
- 55
- Covered by 1 test(s):
- 56
- Covered by 1 test(s):
- 5758
- Covered by 1 test(s):
- 59606162636465666768697071
- Covered by 1 test(s):
- 727374
- Covered by 1 test(s):
- 75
- Covered by 1 test(s):
- 76
- Covered by 1 test(s):
- 77
- Covered by 1 test(s):
- 7879
- Covered by 1 test(s):
- 808182
- Covered by 1 test(s):
- 8384
- Covered by 1 test(s):
- 85
- Covered by 1 test(s):
- 86
- Covered by 1 test(s):
- 878889
- Covered by 1 test(s):
- 909192
- Covered by 1 test(s):
- 9394
- Covered by 1 test(s):
- 959697
- Covered by 1 test(s):
- 9899
- Covered by 1 test(s):
- 100101102
- Covered by 1 test(s):
- 103104
- Covered by 1 test(s):
- 105
- Covered by 1 test(s):
- 106
- Covered by 1 test(s):
- 107108
- Covered by 1 test(s):
- 109110
- Covered by 1 test(s):
- 111112
- Covered by 1 test(s):
- 113
- Covered by 1 test(s):
- 114115
- Covered by 1 test(s):
- 116
- Covered by 1 test(s):
- 117118
- Covered by 1 test(s):
- 119120121122
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query\Drivers\Mysql; /** * MySQL-specific backup, import and creation methods * * @package Query * @subpackage Drivers */ class Util extends \Query\AbstractUtil { /** * Create an SQL backup file for the current database's structure * * @return string */ public function backup_structure() { $string = array(); // Get databases $dbs = $this->get_driver()->get_dbs(); foreach($dbs as &$d) { // Skip built-in dbs if ($d == 'mysql') continue; // Get the list of tables $tables = $this->get_driver()->driver_query("SHOW TABLES FROM `{$d}`", TRUE); foreach($tables as $table) { $array = $this->get_driver()->driver_query("SHOW CREATE TABLE `{$d}`.`{$table}`", FALSE); $row = current($array); if ( ! isset($row['Create Table'])) continue; $string[] = $row['Create Table']; } } return implode("\n\n", $string); } // -------------------------------------------------------------------------- /** * Create an SQL backup file for the current database's data * * @param array $exclude * @return string */ public function backup_data($exclude=array()) { $tables = $this->get_driver()->get_tables(); // Filter out the tables you don't want if( ! empty($exclude)) { $tables = array_diff($tables, $exclude); } $output_sql = ''; // Select the rows from each Table foreach($tables as $t) { $sql = "SELECT * FROM `{$t}`"; $res = $this->get_driver()->query($sql); $rows = $res->fetchAll(\PDO::FETCH_ASSOC); // Skip empty tables if (count($rows) < 1) continue; // Nab the column names by getting the keys of the first row $columns = @array_keys($rows[0]); $insert_rows = array(); // Create the insert statements foreach($rows as $row) { $row = array_values($row); // Workaround for Quercus foreach($row as &$r) { $r = $this->get_driver()->quote($r); } $row = array_map('trim', $row); $row_string = 'INSERT INTO `'.trim($t).'` (`'.implode('`,`', $columns).'`) VALUES ('.implode(',', $row).');'; $row = NULL; $insert_rows[] = $row_string; } $output_sql .= "\n\n".implode("\n", $insert_rows)."\n"; } return $output_sql; } } // End of mysql_util.php |
- Size: 1,859 Bytes - Last Modified: 2015-11-10T09:58:17-05:00
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
- Covered by 1 test(s):
- 5657
- Covered by 1 test(s):
- 5859606162636465666768697071
- Covered by 1 test(s):
- 72
- Covered by 1 test(s):
- 73
- Covered by 1 test(s):
- 7475
- Covered by 1 test(s):
- 7677
- Covered by 1 test(s):
- 7879
- Covered by 1 test(s):
- 8081
- Covered by 1 test(s):
- 8283
- Covered by 1 test(s):
- 84
- Covered by 1 test(s):
- 85
- Covered by 1 test(s):
- 8687
- Covered by 1 test(s):
- 888990
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query\Drivers\Pgsql; /** * PostgreSQL specifc class * * @package Query * @subpackage Drivers */ class Driver extends \Query\AbstractDriver { /** * Connect to a PosgreSQL database * * @codeCoverageIgnore * @param string $dsn * @param string $username * @param string $password * @param array $options */ public function __construct($dsn, $username=null, $password=null, array $options=array()) { if (strpos($dsn, 'pgsql') === FALSE) $dsn = 'pgsql:'.$dsn; parent::__construct($dsn, $username, $password, $options); } // -------------------------------------------------------------------------- /** * Get a list of schemas for the current connection * * @return array */ public function get_schemas() { $sql = <<<SQL SELECT DISTINCT "schemaname" FROM "pg_tables" WHERE "schemaname" NOT LIKE 'pg\_%' AND "schemaname" != 'information_schema' SQL; return $this->driver_query($sql); } // -------------------------------------------------------------------------- /** * Retrieve foreign keys for the table * * @param string $table * @return array */ public function get_fks($table) { $value_map = array( 'c' => 'CASCADE', 'r' => 'RESTRICT', ); $keys = parent::get_fks($table); foreach($keys as &$key) { foreach(array('update', 'delete') AS $type) { if ( ! isset($value_map[$key[$type]])) continue; $key[$type] = $value_map[$key[$type]]; } } return $keys; } } //End of pgsql_driver.php |
- Size: 6,346 Bytes - Last Modified: 2015-11-10T10:05:13-05:00
123456789101112131415161718192021222324252627282930313233
- Covered by 1 test(s):
- 343536373839404142434445
- Covered by 1 test(s):
- 46474849505152535455565758596061
- Covered by 1 test(s):
- 626364656667686970717273747576777879
- Covered by 3 test(s):
- 808182838485868788899091929394959697
- Covered by 1 test(s):
- 9899100101102103104105106107108109110111112113114115
- Covered by 1 test(s):
- 116117118119120121122123124125126127128129130131132
- Covered by 1 test(s):
- 133134135136137138139140141142143144
- Covered by 1 test(s):
- 145146147148149150151152153154155156157158159160161162
- Covered by 1 test(s):
- 163164165166167168169170171172173174175176177178179
- Covered by 1 test(s):
- 180181182183184185186187188189190191192193194195196197198199200201
- Covered by 1 test(s):
- 202
- Covered by 1 test(s):
- 203
- Covered by 1 test(s):
- 204205206207208209210211212213214215216217218219220
- Covered by 1 test(s):
- 221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
- Covered by 1 test(s):
- 253254255256257258259260261262263264
- Covered by 1 test(s):
- 265
- Covered by 1 test(s):
- 266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
- Covered by 1 test(s):
- 295296297298299300
- Covered by 1 test(s):
- 301
- Covered by 1 test(s):
- 302303304
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query\Drivers\Pgsql; /** * PostgreSQL specifc SQL * * @package Query * @subpackage Drivers */ class SQL extends \Query\AbstractSQL { /** * Get the query plan for the sql query * * @param string $sql * @return string */ public function explain($sql) { return "EXPLAIN VERBOSE {$sql}"; } // -------------------------------------------------------------------------- /** * Random ordering keyword * * @return string */ public function random() { return ' RANDOM()'; } // -------------------------------------------------------------------------- /** * Returns sql to list other databases * * @return string */ public function db_list() { return <<<SQL SELECT "datname" FROM "pg_database" WHERE "datname" NOT IN ('template0','template1') ORDER BY "datname" ASC SQL; } // -------------------------------------------------------------------------- /** * Returns sql to list tables * * @return string */ public function table_list() { return <<<SQL SELECT "table_name" FROM "information_schema"."tables" WHERE "table_type" = 'BASE TABLE' AND "table_schema" NOT IN ('pg_catalog', 'information_schema'); SQL; } // -------------------------------------------------------------------------- /** * Returns sql to list system tables * * @return string */ public function system_table_list() { return <<<SQL SELECT "table_name" FROM "information_schema"."tables" WHERE "table_type" = 'BASE TABLE' AND "table_schema" IN ('pg_catalog', 'information_schema'); SQL; } // -------------------------------------------------------------------------- /** * Returns sql to list views * * @return string */ public function view_list() { return <<<SQL SELECT "viewname" FROM "pg_views" WHERE "schemaname" NOT IN ('pg_catalog', 'information_schema') AND "viewname" !~ '^pg_' ORDER BY "viewname" ASC SQL; } // -------------------------------------------------------------------------- /** * Returns sql to list triggers * * @return string */ public function trigger_list() { return <<<SQL SELECT * FROM "information_schema"."triggers" WHERE "trigger_schema" NOT IN ('pg_catalog', 'information_schema') SQL; } // -------------------------------------------------------------------------- /** * Return sql to list functions * * @return NULL */ public function function_list() { return NULL; } // -------------------------------------------------------------------------- /** * Return sql to list stored procedures * * @return string */ public function procedure_list() { return <<<SQL SELECT "routine_name" FROM "information_schema"."routines" WHERE "specific_schema" NOT IN ('pg_catalog', 'information_schema') AND "type_udt_name" != 'trigger'; SQL; } // -------------------------------------------------------------------------- /** * Return sql to list sequences * * @return string */ public function sequence_list() { return <<<SQL SELECT "c"."relname" FROM "pg_class" "c" WHERE "c"."relkind" = 'S' ORDER BY "relname" ASC SQL; } // -------------------------------------------------------------------------- /** * Return sql to list columns of the specified table * * @param string $table * @return string */ public function column_list($table) { return <<<SQL SELECT ordinal_position, column_name, data_type, column_default, is_nullable, character_maximum_length, numeric_precision FROM information_schema.columns WHERE table_name = '{$table}' ORDER BY ordinal_position; SQL; } // -------------------------------------------------------------------------- /** * SQL to show list of field types * * @return string */ public function type_list() { return <<<SQL SELECT "typname" FROM "pg_catalog"."pg_type" WHERE "typname" !~ '^pg_|_' AND "typtype" = 'b' ORDER BY "typname" SQL; } // -------------------------------------------------------------------------- /** * Get the list of foreign keys for the current * table * * @param string $table * @return string */ public function fk_list($table) { return <<<SQL SELECT "att2"."attname" AS "child_column", "cl"."relname" AS "parent_table", "att"."attname" AS "parent_column", "con"."update" AS "update", "con"."update" AS "delete" FROM (SELECT unnest(con1.conkey) AS "parent", unnest(con1.confkey) AS "child", "con1"."confrelid", "con1"."conrelid", "con1"."confupdtype" as "update", "con1"."confdeltype" as "delete" FROM "pg_class" "cl" JOIN "pg_namespace" "ns" ON "cl"."relnamespace" = "ns"."oid" JOIN "pg_constraint" "con1" ON "con1"."conrelid" = "cl"."oid" WHERE "cl"."relname" = '{$table}' AND "ns"."nspname" = 'public' AND "con1"."contype" = 'f' ) "con" JOIN "pg_attribute" "att" ON "att"."attrelid" = "con"."confrelid" AND "att"."attnum" = "con"."child" JOIN "pg_class" "cl" ON "cl"."oid" = "con"."confrelid" JOIN "pg_attribute" "att2" ON "att2"."attrelid" = "con"."conrelid" AND "att2"."attnum" = "con"."parent" SQL; } // -------------------------------------------------------------------------- /** * Get the list of indexes for the current table * * @param string $table * @return array */ public function index_list($table) { return <<<SQL SELECT t.relname AS table_name, i.relname AS index_name, array_to_string(array_agg(a.attname), ', ') AS column_names FROM pg_class t, pg_class i, pg_index ix, pg_attribute a WHERE t.oid = ix.indrelid AND i.oid = ix.indexrelid AND a.attrelid = t.oid AND a.attnum = ANY(ix.indkey) AND t.relkind = 'r' AND t.relname = '{$table}' GROUP BY t.relname, i.relname ORDER BY t.relname, i.relname; SQL; } } //End of pgsql_sql.php |
- Size: 2,156 Bytes - Last Modified: 2015-11-10T10:05:17-05:00
12345678910111213141516171819202122232425262728293031323334
- Covered by 1 test(s):
- 35363738394041424344454647
- Covered by 1 test(s):
- 484950
- Covered by 1 test(s):
- 51
- Covered by 1 test(s):
- 52
- Covered by 1 test(s):
- 53
- Covered by 1 test(s):
- 5455
- Covered by 1 test(s):
- 565758
- Covered by 1 test(s):
- 5960
- Covered by 1 test(s):
- 61
- Covered by 1 test(s):
- 62
- Covered by 1 test(s):
- 636465
- Covered by 1 test(s):
- 6667
- Covered by 1 test(s):
- 686970
- Covered by 1 test(s):
- 7172
- Covered by 1 test(s):
- 737475
- Covered by 1 test(s):
- 7677
- Covered by 1 test(s):
- 787980
- Covered by 1 test(s):
- 81
- Covered by 1 test(s):
- 828384
- Covered by 1 test(s):
- 8586
- Covered by 1 test(s):
- 8788
- Covered by 1 test(s):
- 89
- Covered by 1 test(s):
- 9091
- Covered by 1 test(s):
- 9293
- Covered by 1 test(s):
- 94
- Covered by 1 test(s):
- 9596
- Covered by 1 test(s):
- 979899100
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query\Drivers\Pgsql; /** * Posgres-specific backup, import and creation methods * * @package Query * @subpackage Drivers */ class Util extends \Query\AbstractUtil { /** * Create an SQL backup file for the current database's structure * * @return string */ public function backup_structure() { // TODO Implement Backup function return ''; } // -------------------------------------------------------------------------- /** * Create an SQL backup file for the current database's data * * @param array $exclude * @return string */ public function backup_data($exclude=array()) { $tables = $this->get_driver()->get_tables(); // Filter out the tables you don't want if( ! empty($exclude)) { $tables = array_diff($tables, $exclude); } $output_sql = ''; // Get the data for each object foreach($tables as $t) { $sql = 'SELECT * FROM "'.trim($t).'"'; $res = $this->get_driver()->query($sql); $obj_res = $res->fetchAll(\PDO::FETCH_ASSOC); // Don't add to the file if the table is empty if (count($obj_res) < 1) continue; $res = NULL; // Nab the column names by getting the keys of the first row $columns = @array_keys($obj_res[0]); $insert_rows = array(); // Create the insert statements foreach($obj_res as $row) { $row = array_values($row); // Quote values as needed by type $row = array_map(array($this->get_driver(), 'quote'), $row); $row = array_map('trim', $row); $row_string = 'INSERT INTO "'.trim($t).'" ("'.implode('","', $columns).'") VALUES ('.implode(',', $row).');'; $row = NULL; $insert_rows[] = $row_string; } $obj_res = NULL; $output_sql .= "\n\n".implode("\n", $insert_rows)."\n"; } return $output_sql; } } // End of pgsql_util.php |
- Size: 3,389 Bytes - Last Modified: 2015-11-10T09:58:10-05:00
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
- Covered by 6 test(s):
- 5152
- Covered by 6 test(s):
- 53
- Covered by 6 test(s):
- 545556575859606162636465
- Covered by 3 test(s):
- 66
- Covered by 3 test(s):
- 67
- Covered by 3 test(s):
- 68697071727374757677787980
- Covered by 1 test(s):
- 8182
- Covered by 1 test(s):
- 8384
- Covered by 1 test(s):
- 85
- Covered by 1 test(s):
- 86
- Covered by 1 test(s):
- 87
- Covered by 1 test(s):
- 88
- Covered by 1 test(s):
- 89
- Covered by 1 test(s):
- 90
- Covered by 1 test(s):
- 91
- Covered by 1 test(s):
- 9293
- Covered by 1 test(s):
- 949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
- Covered by 1 test(s):
-
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query\Drivers\Sqlite; /** * SQLite specific class * * @package Query * @subpackage Drivers */ class Driver extends \Query\AbstractDriver { /** * Reference to the last executed sql query * * @var PDOStatement */ protected $statement; /** * SQLite has a truncate optimization, * but no support for the actual keyword * @var bool */ protected $has_truncate = FALSE; /** * Open SQLite Database * * @param string $dsn * @param string $user * @param string $pass * @param array $driver_options */ public function __construct($dsn, $user=NULL, $pass=NULL, array $driver_options=array()) { if (strpos($dsn, 'sqlite:') === FALSE) $dsn = "sqlite:{$dsn}"; parent::__construct($dsn, $user, $pass); } // -------------------------------------------------------------------------- /** * List tables for the current database * * @return mixed */ public function get_tables() { $sql = $this->sql->table_list(); $res = $this->query($sql); return db_filter($res->fetchAll(\PDO::FETCH_ASSOC), 'name'); } // -------------------------------------------------------------------------- /** * Retrieve foreign keys for the table * * @param string $table * @return array */ public function get_fks($table) { $return_rows = array(); foreach(parent::get_fks($table) as $row) { $return_rows[] = array( 'child_column' => $row['from'], 'parent_table' => $row['table'], 'parent_column' => $row['to'], 'update' => $row['on_update'], 'delete' => $row['on_delete'] ); } return $return_rows; } // -------------------------------------------------------------------------- /** * Create sql for batch insert * * @codeCoverageIgnore * @param string $table * @param array $data * @return string */ public function insert_batch($table, $data=array()) { // If greater than version 3.7.11, supports the same syntax as // MySQL and Postgres if (version_compare($this->getAttribute(\PDO::ATTR_SERVER_VERSION), '3.7.11', '>=')) { return parent::insert_batch($table, $data); } // -------------------------------------------------------------------------- // Otherwise, do a union query as an analogue to a 'proper' batch insert // -------------------------------------------------------------------------- // Each member of the data array needs to be an array if ( ! is_array(current($data))) return NULL; // Start the block of sql statements $table = $this->quote_table($table); $sql = "INSERT INTO {$table} \n"; // Create a key-value mapping for each field $first = array_shift($data); $cols = array(); foreach($first as $colname => $datum) { $cols[] = $this->_quote($datum) . ' AS ' . $this->quote_ident($colname); } $sql .= "SELECT " . implode(', ', $cols) . "\n"; foreach($data as $union) { $vals = array_map(array($this, 'quote'), $union); $sql .= "UNION SELECT " . implode(',', $vals) . "\n"; } return array($sql, NULL); } } //End of sqlite_driver.php |
- Size: 3,918 Bytes - Last Modified: 2015-11-10T10:05:21-05:00
12345678910111213141516171819202122232425262728293031323334
- Covered by 1 test(s):
- 353637383940414243444546
- Covered by 1 test(s):
- 474849505152535455565758
- Covered by 1 test(s):
- 596061626364656667686970717273747576
- Covered by 3 test(s):
- 777879808182838485868788
- Covered by 1 test(s):
- 8990919293949596979899100101102
- Covered by 1 test(s):
- 103104105106107108109110111112113114
- Covered by 1 test(s):
- 115116117118119120121122123124125126
- Covered by 2 test(s):
- 127128129130131132133134135136137138
- Covered by 2 test(s):
- 139140141142143144145146147148149150
- Covered by 2 test(s):
- 151152153154155156157158159160161162
- Covered by 1 test(s):
- 163164165166167168169170171172173174175
- Covered by 1 test(s):
- 176177178179180181182183184185186187188189
- Covered by 1 test(s):
- 190191192193194195196197198199200201202
- Covered by 1 test(s):
- 203204205206
- Covered by 1 test(s):
-
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query\Drivers\Sqlite; /** * SQLite Specific SQL * * @package Query * @subpackage Drivers */ class SQL extends \Query\AbstractSQL { /** * Get the query plan for the sql query * * @param string $sql * @return string */ public function explain($sql) { return "EXPLAIN QUERY PLAN {$sql}"; } // -------------------------------------------------------------------------- /** * Random ordering keyword * * @return string */ public function random() { return ' RANDOM()'; } // -------------------------------------------------------------------------- /** * Returns sql to list other databases * * @return string */ public function db_list() { return 'PRAGMA database_list'; } // -------------------------------------------------------------------------- /** * Returns sql to list tables * * @return string */ public function table_list() { return <<<SQL SELECT DISTINCT "name" FROM "sqlite_master" WHERE "type"='table' AND "name" NOT LIKE 'sqlite_%' ORDER BY "name" DESC SQL; } // -------------------------------------------------------------------------- /** * List the system tables * * @return string[] */ public function system_table_list() { return array('sqlite_master', 'sqlite_temp_master', 'sqlite_sequence'); } // -------------------------------------------------------------------------- /** * Returns sql to list views * * @return string */ public function view_list() { return <<<SQL SELECT "name" FROM "sqlite_master" WHERE "type" = 'view' SQL; } // -------------------------------------------------------------------------- /** * Returns sql to list triggers * * @return string */ public function trigger_list() { return 'SELECT "name" FROM "sqlite_master" WHERE "type"=\'trigger\''; } // -------------------------------------------------------------------------- /** * Return sql to list functions * * @return NULL */ public function function_list() { return NULL; } // -------------------------------------------------------------------------- /** * Return sql to list stored procedures * * @return NULL */ public function procedure_list() { return NULL; } // -------------------------------------------------------------------------- /** * Return sql to list sequences * * @return NULL */ public function sequence_list() { return NULL; } // -------------------------------------------------------------------------- /** * SQL to show list of field types * * @return string[] */ public function type_list() { return array('INTEGER', 'REAL', 'TEXT', 'BLOB'); } // -------------------------------------------------------------------------- /** * SQL to show infromation about columns in a table * * @param string $table * @return string */ public function column_list($table) { return 'PRAGMA table_info("'.$table.'")'; } // -------------------------------------------------------------------------- /** * Get the list of foreign keys for the current * table * * @param string $table * @return string */ public function fk_list($table) { return 'PRAGMA foreign_key_list("' . $table . '")'; } // -------------------------------------------------------------------------- /** * Get the list of indexes for the current table * * @param string $table * @return string */ public function index_list($table) { return 'PRAGMA index_list("' . $table . '")'; } } //End of sqlite_sql.php |
- Size: 2,713 Bytes - Last Modified: 2015-11-10T11:29:05-05:00
123456789101112131415161718192021222324252627282930313233343536373839
- Covered by 1 test(s):
- 4041
- Covered by 1 test(s):
- 42
- Covered by 1 test(s):
- 43
- Covered by 1 test(s):
- 44
- Covered by 1 test(s):
- 4546
- Covered by 1 test(s):
- 47
- Covered by 1 test(s):
- 4849
- Covered by 1 test(s):
- 5051
- Covered by 1 test(s):
- 525354
- Covered by 1 test(s):
- 5556
- Covered by 1 test(s):
- 57
- Covered by 1 test(s):
- 58
- Covered by 1 test(s):
- 5960
- Covered by 1 test(s):
- 616263
- Covered by 1 test(s):
- 646566
- Covered by 1 test(s):
- 6768
- Covered by 1 test(s):
- 697071
- Covered by 1 test(s):
- 7273
- Covered by 1 test(s):
- 747576
- Covered by 1 test(s):
- 7778
- Covered by 1 test(s):
- 79
- Covered by 1 test(s):
- 8081
- Covered by 1 test(s):
- 8283
- Covered by 1 test(s):
- 8485
- Covered by 1 test(s):
- 86
- Covered by 1 test(s):
- 8788
- Covered by 1 test(s):
- 8990
- Covered by 1 test(s):
- 91
- Covered by 1 test(s):
- 9293
- Covered by 1 test(s):
- 949596979899100101102103104105106
- Covered by 1 test(s):
- 107
- Covered by 1 test(s):
- 108
- Covered by 1 test(s):
- 109110
- Covered by 1 test(s):
- 111112
- Covered by 1 test(s):
- 113114
- Covered by 1 test(s):
- 115
- Covered by 1 test(s):
- 116117
- Covered by 1 test(s):
- 118119120
- Covered by 1 test(s):
-
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query\Drivers\Sqlite; /** * SQLite-specific backup, import and creation methods * * @package Query * @subpackage Drivers * @method mixed query(string $sql) * @method string quote(string $str) */ class Util extends \Query\AbstractUtil { /** * Create an SQL backup file for the current database's data * * @param array $excluded * @return string */ public function backup_data($excluded=array()) { // Get a list of all the objects $sql = 'SELECT DISTINCT "name" FROM "sqlite_master" WHERE "type"=\'table\''; if( ! empty($excluded)) { $sql .= " AND \"name\" NOT IN('".implode("','", $excluded)."')"; } $res = $this->get_driver()->query($sql); $result = $res->fetchAll(\PDO::FETCH_ASSOC); unset($res); $output_sql = ''; // Get the data for each object foreach($result as $r) { $sql = 'SELECT * FROM "'.$r['name'].'"'; $res = $this->get_driver()->query($sql); $obj_res = $res->fetchAll(\PDO::FETCH_ASSOC); unset($res); // If the row is empty, continue; if (empty($obj_res)) continue; // Nab the column names by getting the keys of the first row $columns = array_keys(current($obj_res)); $insert_rows = array(); // Create the insert statements foreach($obj_res as $row) { $row = array_values($row); // Quote values as needed by type for($i=0, $icount=count($row); $i<$icount; $i++) { $row[$i] = (is_numeric($row[$i])) ? $row[$i] : $this->get_driver()->quote($row[$i]); } $row_string = 'INSERT INTO "'.$r['name'].'" ("'.implode('","', $columns).'") VALUES ('.implode(',', $row).');'; unset($row); $insert_rows[] = $row_string; } unset($obj_res); $output_sql .= "\n\n".implode("\n", $insert_rows); } return $output_sql; } // -------------------------------------------------------------------------- /** * Create an SQL backup file for the current database's structure * * @return string */ public function backup_structure() { // Fairly easy for SQLite...just query the master table $sql = 'SELECT "sql" FROM "sqlite_master"'; $res = $this->get_driver()->query($sql); $result = $res->fetchAll(\PDO::FETCH_ASSOC); $sql_array = array(); foreach($result as $r) { $sql_array[] = $r['sql']; } return implode(";\n", $sql_array) . ";"; } } // End of sqlite_util.php |
- Size: 21,089 Bytes - Last Modified: 2015-11-10T11:16:37-05:00
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
- Covered by 3 test(s):
- 74
- Covered by 3 test(s):
- 7576
- Covered by 3 test(s):
- 777879
- Covered by 3 test(s):
- 80
- Covered by 3 test(s):
- 81
- Covered by 3 test(s):
- 828384858687888990919293949596979899100101102103104105106107
- Covered by 49 test(s):
- 108109
- Covered by 49 test(s):
- 110111
- Covered by 49 test(s):
- 112113
- Covered by 49 test(s):
- 114
- Covered by 49 test(s):
- 115
- Covered by 45 test(s):
- 116117
- Covered by 49 test(s):
- 118119
- Covered by 45 test(s):
- 120121
- Covered by 4 test(s):
- 122123124125126127128129130131132133134135136137
- Covered by 72 test(s):
- 138
- Covered by 72 test(s):
- 139140141
- Covered by 72 test(s):
- 142143
- Covered by 72 test(s):
- 144
- Covered by 72 test(s):
- 145
- Covered by 64 test(s):
- 146
- Covered by 64 test(s):
- 147
- Covered by 64 test(s):
- 148
- Covered by 72 test(s):
- 149150151
- Covered by 72 test(s):
- 152153
- Covered by 72 test(s):
- 154155156
- Covered by 72 test(s):
- 157158
- Covered by 72 test(s):
- 159
- Covered by 72 test(s):
- 160
- Covered by 64 test(s):
- 161
- Covered by 64 test(s):
- 162
- Covered by 72 test(s):
- 163164
- Covered by 72 test(s):
- 165166
- Covered by 72 test(s):
- 167168
- Covered by 72 test(s):
- 169170171172173174175176177178179180181182183
- Covered by 4 test(s):
- 184
- Covered by 4 test(s):
- 185186187188189190191192193194195196197198199
- Covered by 4 test(s):
- 200
- Covered by 4 test(s):
- 201202203204205206207208209210211212213214215
- Covered by 4 test(s):
- 216
- Covered by 4 test(s):
- 217218219220221222223224225226227228229230231
- Covered by 8 test(s):
- 232
- Covered by 8 test(s):
- 233234235236237238239240241242243244245
- Covered by 4 test(s):
- 246
- Covered by 4 test(s):
- 247248249250251252253254255256257258
- Covered by 4 test(s):
- 259
- Covered by 4 test(s):
- 260261262263264265266267268269270271272273
- Covered by 187 test(s):
- 274
- Covered by 187 test(s):
- 275276277
- Covered by 187 test(s):
- 278
- Covered by 187 test(s):
- 279280281
- Covered by 187 test(s):
- 282283
- Covered by 187 test(s):
- 284285286287288289290291292293294295296297298299300
- Covered by 24 test(s):
- 301302303304305306307308309310311312313314315
- Covered by 4 test(s):
- 316317318319320321322323324325326327328329330
- Covered by 4 test(s):
- 331332333334335336337338339340341342343344345
- Covered by 4 test(s):
- 346347348349350351352353354355356357358359360361
- Covered by 8 test(s):
- 362363364365366367368369370371372373374375
- Covered by 4 test(s):
- 376377378379380381382383384385386387388389390391392393394
- Covered by 100 test(s):
- 395396397398399400401402403404405406407408
- Covered by 8 test(s):
- 409410411412413414415416417418419420421422
- Covered by 4 test(s):
- 423424425426427428429430431432433434435436
- Covered by 4 test(s):
- 437438439440441442443444445446447448449450
- Covered by 4 test(s):
- 451452453454455456457458459460461462463464
- Covered by 4 test(s):
- 465466467468469470471472473474475476477478479480
- Covered by 32 test(s):
- 481
- Covered by 32 test(s):
- 482483484485
- Covered by 32 test(s):
- 486487488
- Covered by 32 test(s):
- 489
- Covered by 32 test(s):
- 490491
- Covered by 32 test(s):
- 492493494495496497498499500501502503504505506507
- Covered by 16 test(s):
- 508
- Covered by 16 test(s):
- 509
- Covered by 16 test(s):
- 510
- Covered by 16 test(s):
- 511512513
- Covered by 16 test(s):
- 514
- Covered by 16 test(s):
- 515516
- Covered by 16 test(s):
- 517518
- Covered by 16 test(s):
- 519520521522523524525526527528529530531
- Covered by 16 test(s):
- 532
- Covered by 16 test(s):
- 533
- Covered by 4 test(s):
- 534
- Covered by 4 test(s):
- 535
- Covered by 4 test(s):
- 536537538
- Covered by 16 test(s):
- 539540541
- Covered by 16 test(s):
- 542543
- Covered by 16 test(s):
- 544545546547548549550551552553554555556557558559
- Covered by 16 test(s):
- 560
- Covered by 16 test(s):
- 561
- Covered by 4 test(s):
- 562
- Covered by 4 test(s):
- 563
- Covered by 4 test(s):
- 564565566
- Covered by 16 test(s):
- 567
- Covered by 16 test(s):
- 568569
- Covered by 16 test(s):
- 570571572
- Covered by 16 test(s):
- 573574
- Covered by 16 test(s):
- 575
- Covered by 16 test(s):
- 576577578
- Covered by 16 test(s):
- 579
- Covered by 16 test(s):
- 580
- Covered by 16 test(s):
- 581582
- Covered by 16 test(s):
- 583584585586587588589590591592593594595596
- Covered by 68 test(s):
- 597
- Covered by 68 test(s):
- 598599
- Covered by 68 test(s):
- 600601602603604605606607608609610611612613
- Covered by 16 test(s):
- 614615
- Covered by 16 test(s):
- 616617
- Covered by 16 test(s):
- 618619620621622623624625626627628629630
- Covered by 4 test(s):
- 631632
- Covered by 4 test(s):
- 633634635636637638639640641642643644645
- Covered by 8 test(s):
- 646647
- Covered by 8 test(s):
- 648649650651652653654655656657658659
- Covered by 16 test(s):
- 660661
- Covered by 16 test(s):
- 662663664665666667668669670671672673674675676677678679680
- Covered by 179 test(s):
- 681682683
- Covered by 179 test(s):
- 684685
- Covered by 179 test(s):
- 686687688689690691692693694695696697698699700701702
- Covered by 4 test(s):
- 703704705
- Covered by 4 test(s):
- 706707708709710711712713714715716717718
- Covered by 4 test(s):
- 719
- Covered by 4 test(s):
- 720
- Covered by 4 test(s):
- 721722723724725726727728729730731732733734735
- Covered by 8 test(s):
- 736737
- Covered by 8 test(s):
- 738
- Covered by 8 test(s):
- 739740
- Covered by 8 test(s):
- 741742743744745746747748749750751752753754755
- Covered by 12 test(s):
- 756757
- Covered by 12 test(s):
- 758759760761762763764765766767768769770771772
- Covered by 4 test(s):
- 773774
- Covered by 4 test(s):
- 775
- Covered by 4 test(s):
- 776
- Covered by 4 test(s):
- 777778779780781782783784785786787788789790791
- Covered by 12 test(s):
- 792793
- Covered by 12 test(s):
- 794795796797798799800801802803804805806807808
- Covered by 8 test(s):
- 809810
- Covered by 8 test(s):
- 811812813814815816817818819820821822823824825826827828829
- Covered by 5 test(s):
- 830831
- Covered by 5 test(s):
- 832833834835836837838839840841842843844845
- Covered by 4 test(s):
- 846847848849850851852853854855856857858859
- Covered by 4 test(s):
- 860861862863864865866867868869870871872873
- Covered by 4 test(s):
- 874875876877878879880881882883884885886887888889
- Covered by 236 test(s):
- 890891
- Covered by 236 test(s):
- 892
- Covered by 236 test(s):
- 893894895
- Covered by 236 test(s):
- 896897
- Covered by 236 test(s):
- 898
- Covered by 236 test(s):
- 899
- Covered by 236 test(s):
- 900901
- Covered by 1 test(s):
-
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query; // -------------------------------------------------------------------------- /** * Convenience class for creating sql queries - also the class that * instantiates the specific db driver * * @package Query * @subpackage Query_Builder */ class QueryBuilder extends AbstractQueryBuilder implements QueryBuilderInterface { /** * String class values to be reset * * @var array */ private $string_vars = array( 'select_string', 'from_string', 'set_string', 'order_string', 'group_string', 'limit', 'offset', 'explain', ); /** * Array class variables to be reset * * @var array */ private $array_vars = array( 'set_array_keys', 'order_array', 'group_array', 'values', 'where_values', 'query_map', 'having_map' ); // -------------------------------------------------------------------------- // ! Methods // -------------------------------------------------------------------------- /** * Constructor * * @param DriverInterface $db * @param QueryParser $parser */ public function __construct(DriverInterface $db, QueryParser $parser) { // Inject driver and parser $this->db = $db; $this->parser = $parser; $this->queries['total_time'] = 0; // Alias driver sql and util classes $this->sql = $this->db->get_sql(); $this->util = $this->db->get_util(); } // -------------------------------------------------------------------------- /** * Destructor * @codeCoverageIgnore */ public function __destruct() { $this->db = NULL; } // -------------------------------------------------------------------------- /** * Calls a function further down the inheritence chain * * @param string $name * @param array $params * @return mixed * @throws \BadMethodCallException */ public function __call($name, $params) { // Allow camel-case method calls $snake_name = \from_camel_case($name); foreach(array($this, $this->db) as $object) { foreach(array($name, $snake_name) as $method_name) { if (method_exists($object, $method_name)) { return call_user_func_array(array($object, $method_name), $params); } } } throw new \BadMethodCallException("Method does not exist"); } // -------------------------------------------------------------------------- // ! Select Queries // -------------------------------------------------------------------------- /** * Specifies rows to select in a query * * @param string $fields * @return Query_Builder */ public function select($fields) { // Split fields by comma $fields_array = explode(",", $fields); $fields_array = array_map('mb_trim', $fields_array); // Split on 'As' foreach ($fields_array as $key => $field) { if (stripos($field, 'as') !== FALSE) { $fields_array[$key] = preg_split('` as `i', $field); $fields_array[$key] = array_map('mb_trim', $fields_array[$key]); } } // Quote the identifiers $safe_array = $this->db->quote_ident($fields_array); unset($fields_array); // Join the strings back together for($i = 0, $c = count($safe_array); $i < $c; $i++) { if (is_array($safe_array[$i])) { $safe_array[$i] = implode(' AS ', $safe_array[$i]); } } $this->select_string .= implode(', ', $safe_array); unset($safe_array); return $this; } // -------------------------------------------------------------------------- /** * Selects the maximum value of a field from a query * * @param string $field * @param string|FALSE $as * @return Query_Builder */ public function select_max($field, $as=FALSE) { // Create the select string $this->select_string .= ' MAX'.$this->_select($field, $as); return $this; } // -------------------------------------------------------------------------- /** * Selects the minimum value of a field from a query * * @param string $field * @param string|bool $as * @return Query_Builder */ public function select_min($field, $as=FALSE) { // Create the select string $this->select_string .= ' MIN'.$this->_select($field, $as); return $this; } // -------------------------------------------------------------------------- /** * Selects the average value of a field from a query * * @param string $field * @param string|bool $as * @return Query_Builder */ public function select_avg($field, $as=FALSE) { // Create the select string $this->select_string .= ' AVG'.$this->_select($field, $as); return $this; } // -------------------------------------------------------------------------- /** * Selects the sum of a field from a query * * @param string $field * @param string|bool $as * @return Query_Builder */ public function select_sum($field, $as=FALSE) { // Create the select string $this->select_string .= ' SUM'.$this->_select($field, $as); return $this; } // -------------------------------------------------------------------------- /** * Adds the 'distinct' keyword to a query * * @return Query_Builder */ public function distinct() { // Prepend the keyword to the select string $this->select_string = ' DISTINCT '.$this->select_string; return $this; } // -------------------------------------------------------------------------- /** * Tell the database to give you the query plan instead of result set * * @return Query_Builder */ public function explain() { $this->explain = TRUE; return $this; } // -------------------------------------------------------------------------- /** * Specify the database table to select from * * @param string $tblname * @return Query_Builder */ public function from($tblname) { // Split identifiers on spaces $ident_array = explode(' ', \mb_trim($tblname)); $ident_array = array_map('\\mb_trim', $ident_array); // Quote the identifiers $ident_array[0] = $this->db->quote_table($ident_array[0]); $ident_array = $this->db->quote_ident($ident_array); // Paste it back together $this->from_string = implode(' ', $ident_array); return $this; } // -------------------------------------------------------------------------- // ! 'Like' methods // -------------------------------------------------------------------------- /** * Creates a Like clause in the sql statement * * @param string $field * @param mixed $val * @param string $pos * @return Query_Builder */ public function like($field, $val, $pos='both') { return $this->_like($field, $val, $pos, 'LIKE', 'AND'); } // -------------------------------------------------------------------------- /** * Generates an OR Like clause * * @param string $field * @param mixed $val * @param string $pos * @return Query_Builder */ public function or_like($field, $val, $pos='both') { return $this->_like($field, $val, $pos, 'LIKE', 'OR'); } // -------------------------------------------------------------------------- /** * Generates a NOT LIKE clause * * @param string $field * @param mixed $val * @param string $pos * @return Query_Builder */ public function not_like($field, $val, $pos='both') { return $this->_like($field, $val, $pos, 'NOT LIKE', 'AND'); } // -------------------------------------------------------------------------- /** * Generates a OR NOT LIKE clause * * @param string $field * @param mixed $val * @param string $pos * @return Query_Builder */ public function or_not_like($field, $val, $pos='both') { return $this->_like($field, $val, $pos, 'NOT LIKE', 'OR'); } // -------------------------------------------------------------------------- // ! Having methods // -------------------------------------------------------------------------- /** * Generates a 'Having' clause * * @param mixed $key * @param mixed $val * @return Query_Builder */ public function having($key, $val=array()) { return $this->_having($key, $val, 'AND'); } // -------------------------------------------------------------------------- /** * Generates a 'Having' clause prefixed with 'OR' * * @param mixed $key * @param mixed $val * @return Query_Builder */ public function or_having($key, $val=array()) { return $this->_having($key, $val, 'OR'); } // -------------------------------------------------------------------------- // ! 'Where' methods // -------------------------------------------------------------------------- /** * Specify condition(s) in the where clause of a query * Note: this function works with key / value, or a * passed array with key / value pairs * * @param mixed $key * @param mixed $val * @param mixed $escape * @return Query_Builder */ public function where($key, $val=array(), $escape=NULL) { return $this->_where_string($key, $val, 'AND'); } // -------------------------------------------------------------------------- /** * Where clause prefixed with "OR" * * @param string $key * @param mixed $val * @return Query_Builder */ public function or_where($key, $val=array()) { return $this->_where_string($key, $val, 'OR'); } // -------------------------------------------------------------------------- /** * Where clause with 'IN' statement * * @param mixed $field * @param mixed $val * @return Query_Builder */ public function where_in($field, $val=array()) { return $this->_where_in($field, $val); } // -------------------------------------------------------------------------- /** * Where in statement prefixed with "or" * * @param string $field * @param mixed $val * @return Query_Builder */ public function or_where_in($field, $val=array()) { return $this->_where_in($field, $val, 'IN', 'OR'); } // -------------------------------------------------------------------------- /** * WHERE NOT IN (FOO) clause * * @param string $field * @param mixed $val * @return Query_Builder */ public function where_not_in($field, $val=array()) { return $this->_where_in($field, $val, 'NOT IN', 'AND'); } // -------------------------------------------------------------------------- /** * OR WHERE NOT IN (FOO) clause * * @param string $field * @param mixed $val * @return Query_Builder */ public function or_where_not_in($field, $val=array()) { return $this->_where_in($field, $val, 'NOT IN', 'OR'); } // -------------------------------------------------------------------------- // ! Other Query Modifier methods // -------------------------------------------------------------------------- /** * Sets values for inserts / updates / deletes * * @param mixed $key * @param mixed $val * @return Query_Builder */ public function set($key, $val = NULL) { $this->_mixed_set($this->set_array_keys, $key, $val, self::KEY); $this->_mixed_set($this->values, $key, $val, self::VALUE); // Use the keys of the array to make the insert/update string // Escape the field names $this->set_array_keys = array_map(array($this->db, '_quote'), $this->set_array_keys); // Generate the "set" string $this->set_string = implode('=?,', $this->set_array_keys); $this->set_string .= '=?'; return $this; } // -------------------------------------------------------------------------- /** * Creates a join phrase in a compiled query * * @param string $table * @param string $condition * @param string $type * @return Query_Builder */ public function join($table, $condition, $type='') { // Prefix and quote table name $table = explode(' ', mb_trim($table)); $table[0] = $this->db->quote_table($table[0]); $table = $this->db->quote_ident($table); $table = implode(' ', $table); // Parse out the join condition $parsed_condition = $this->parser->compile_join($condition); $condition = $table . ' ON ' . $parsed_condition; $this->_append_map("\n" . strtoupper($type) . ' JOIN ', $condition, 'join'); return $this; } // -------------------------------------------------------------------------- /** * Group the results by the selected field(s) * * @param mixed $field * @return Query_Builder */ public function group_by($field) { if ( ! is_scalar($field)) { $new_group_array = array_map(array($this->db, 'quote_ident'), $field); $this->group_array = array_merge($this->group_array, $new_group_array); } else { $this->group_array[] = $this->db->quote_ident($field); } $this->group_string = ' GROUP BY ' . implode(',', $this->group_array); return $this; } // -------------------------------------------------------------------------- /** * Order the results by the selected field(s) * * @param string $field * @param string $type * @return Query_Builder */ public function order_by($field, $type="") { // When ordering by random, do an ascending order if the driver // doesn't support random ordering if (stripos($type, 'rand') !== FALSE) { $rand = $this->sql->random(); $type = ($rand !== FALSE) ? $rand : 'ASC'; } // Set fields for later manipulation $field = $this->db->quote_ident($field); $this->order_array[$field] = $type; $order_clauses = array(); // Flatten key/val pairs into an array of space-separated pairs foreach($this->order_array as $k => $v) { $order_clauses[] = $k . ' ' . strtoupper($v); } // Set the final string $this->order_string = ( ! isset($rand)) ? "\nORDER BY ".implode(', ', $order_clauses) : "\nORDER BY".$rand; return $this; } // -------------------------------------------------------------------------- /** * Set a limit on the current sql statement * * @param int $limit * @param int|bool $offset * @return Query_Builder */ public function limit($limit, $offset=FALSE) { $this->limit = (int) $limit; $this->offset = $offset; return $this; } // -------------------------------------------------------------------------- // ! Query Grouping Methods // -------------------------------------------------------------------------- /** * Adds a paren to the current query for query grouping * * @return Query_Builder */ public function group_start() { $conj = (empty($this->query_map)) ? ' WHERE ' : ' '; $this->_append_map($conj, '(', 'group_start'); return $this; } // -------------------------------------------------------------------------- /** * Adds a paren to the current query for query grouping, * prefixed with 'OR' * * @return Query_Builder */ public function or_group_start() { $this->_append_map('', ' OR (', 'group_start'); return $this; } // -------------------------------------------------------------------------- /** * Adds a paren to the current query for query grouping, * prefixed with 'OR NOT' * * @return Query_Builder */ public function or_not_group_start() { $this->_append_map('', ' OR NOT (', 'group_start'); return $this; } // -------------------------------------------------------------------------- /** * Ends a query group * * @return Query_Builder */ public function group_end() { $this->_append_map('', ')', 'group_end'); return $this; } // -------------------------------------------------------------------------- // ! Query execution methods // -------------------------------------------------------------------------- /** * Select and retrieve all records from the current table, and/or * execute current compiled query * * @param $table * @param int|bool $limit * @param int|bool $offset * @return \PDOStatement */ public function get($table='', $limit=FALSE, $offset=FALSE) { // Set the table if ( ! empty($table)) $this->from($table); // Set the limit, if it exists if (is_int($limit)) $this->limit($limit, $offset); return $this->_run("get", $table); } // -------------------------------------------------------------------------- /** * Convenience method for get() with a where clause * * @param string $table * @param array $where * @param int|bool $limit * @param int|bool $offset * @return \PDOStatement */ public function get_where($table, $where=array(), $limit=FALSE, $offset=FALSE) { // Create the where clause $this->where($where); // Return the result return $this->get($table, $limit, $offset); } // -------------------------------------------------------------------------- /** * Retreive the number of rows in the selected table * * @param string $table * @return int */ public function count_all($table) { $sql = 'SELECT * FROM '.$this->db->quote_table($table); $res = $this->db->query($sql); return (int) count($res->fetchAll()); } // -------------------------------------------------------------------------- /** * Retrieve the number of results for the generated query - used * in place of the get() method * * @param string $table * @return int */ public function count_all_results($table='') { // Set the table if ( ! empty($table)) $this->from($table); $result = $this->_run('get', $table); $rows = $result->fetchAll(); return (int) count($rows); } // -------------------------------------------------------------------------- /** * Creates an insert clause, and executes it * * @param string $table * @param mixed $data * @return \PDOStatement */ public function insert($table, $data=array()) { // No use duplicating logic! if ( ! empty($data)) $this->set($data); return $this->_run("insert", $table); } // -------------------------------------------------------------------------- /** * Creates and executes a batch insertion query * * @param string $table * @param array $data * @return \PDOStatement */ public function insert_batch($table, $data=array()) { // Get the generated values and sql string list($sql, $data) = $this->db->insert_batch($table, $data); return ( ! is_null($sql)) ? $this->_run('', $table, $sql, $data) : NULL; } // -------------------------------------------------------------------------- /** * Creates an update clause, and executes it * * @param string $table * @param mixed $data * @return \PDOStatement */ public function update($table, $data=array()) { // No use duplicating logic! if ( ! empty($data)) $this->set($data); return $this->_run("update", $table); } // -------------------------------------------------------------------------- /** * Deletes data from a table * * @param string $table * @param mixed $where * @return \PDOStatement */ public function delete($table, $where='') { // Set the where clause if ( ! empty($where)) $this->where($where); return $this->_run("delete", $table); } // -------------------------------------------------------------------------- // ! SQL Returning Methods // -------------------------------------------------------------------------- /** * Returns the generated 'select' sql query * * @param string $table * @param bool $reset * @return string */ public function get_compiled_select($table='', $reset=TRUE) { // Set the table if ( ! empty($table)) $this->from($table); return $this->_get_compile('select', $table, $reset); } // -------------------------------------------------------------------------- /** * Returns the generated 'insert' sql query * * @param string $table * @param bool $reset * @return string */ public function get_compiled_insert($table, $reset=TRUE) { return $this->_get_compile('insert', $table, $reset); } // -------------------------------------------------------------------------- /** * Returns the generated 'update' sql query * * @param string $table * @param bool $reset * @return string */ public function get_compiled_update($table='', $reset=TRUE) { return $this->_get_compile('update', $table, $reset); } // -------------------------------------------------------------------------- /** * Returns the generated 'delete' sql query * * @param string $table * @param bool $reset * @return string */ public function get_compiled_delete($table="", $reset=TRUE) { return $this->_get_compile('delete', $table, $reset); } // -------------------------------------------------------------------------- // ! Miscellaneous Methods // -------------------------------------------------------------------------- /** * Clear out the class variables, so the next query can be run * * @return void */ public function reset_query() { // Reset strings and booleans foreach($this->string_vars as $var) { $this->$var = NULL; } // Reset arrays foreach($this->array_vars as $var) { $this->$var = array(); } } } // End of query_builder.php |
- Size: 12,435 Bytes - Last Modified: 2015-11-10T09:59:33-05:00
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504 | <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query; /** * Interface defining the Query Builder class * * @package Query * @subpackage Query_Builder */ interface QueryBuilderInterface { // -------------------------------------------------------------------------- // ! Select Queries // -------------------------------------------------------------------------- /** * Specifies rows to select in a query * * @param string $fields * @return Query_Builder */ public function select($fields); // -------------------------------------------------------------------------- /** * Selects the maximum value of a field from a query * * @param string $field * @param string|bool $as * @return Query_Builder */ public function select_max($field, $as=FALSE); // -------------------------------------------------------------------------- /** * Selects the minimum value of a field from a query * * @param string $field * @param string|bool $as * @return Query_Builder */ public function select_min($field, $as=FALSE); // -------------------------------------------------------------------------- /** * Selects the average value of a field from a query * * @param string $field * @param string|bool $as * @return Query_Builder */ public function select_avg($field, $as=FALSE); // -------------------------------------------------------------------------- /** * Selects the sum of a field from a query * * @param string $field * @param string|bool $as * @return Query_Builder */ public function select_sum($field, $as=FALSE); // -------------------------------------------------------------------------- /** * Adds the 'distinct' keyword to a query * * @return Query_Builder */ public function distinct(); // -------------------------------------------------------------------------- /** * Shows the query plan for the query * * @return Query_Builder */ public function explain(); // -------------------------------------------------------------------------- /** * Specify the database table to select from * * @param string $tblname * @return Query_Builder */ public function from($tblname); // -------------------------------------------------------------------------- // ! 'Like' methods // -------------------------------------------------------------------------- /** * Creates a Like clause in the sql statement * * @param string $field * @param mixed $val * @param string $pos * @return Query_Builder */ public function like($field, $val, $pos='both'); // -------------------------------------------------------------------------- /** * Generates an OR Like clause * * @param string $field * @param mixed $val * @param string $pos * @return Query_Builder */ public function or_like($field, $val, $pos='both'); // -------------------------------------------------------------------------- /** * Generates a NOT LIKE clause * * @param string $field * @param mixed $val * @param string $pos * @return Query_Builder */ public function not_like($field, $val, $pos='both'); // -------------------------------------------------------------------------- /** * Generates a OR NOT LIKE clause * * @param string $field * @param mixed $val * @param string $pos * @return Query_Builder */ public function or_not_like($field, $val, $pos='both'); // -------------------------------------------------------------------------- // ! Having methods // -------------------------------------------------------------------------- /** * Generates a 'Having' clause * * @param mixed $key * @param mixed $val * @return Query_Builder */ public function having($key, $val=array()); // -------------------------------------------------------------------------- /** * Generates a 'Having' clause prefixed with 'OR' * * @param mixed $key * @param mixed $val * @return Query_Builder */ public function or_having($key, $val=array()); // -------------------------------------------------------------------------- // ! 'Where' methods // -------------------------------------------------------------------------- /** * Specify condition(s) in the where clause of a query * Note: this function works with key / value, or a * passed array with key / value pairs * * @param mixed $key * @param mixed $val * @param bool $escape * @return Query_Builder */ public function where($key, $val=array(), $escape = NULL); // -------------------------------------------------------------------------- /** * Where clause prefixed with "OR" * * @param string $key * @param mixed $val * @return Query_Builder */ public function or_where($key, $val=array()); // -------------------------------------------------------------------------- /** * Where clause with 'IN' statement * * @param mixed $field * @param mixed $val * @return Query_Builder */ public function where_in($field, $val=array()); // -------------------------------------------------------------------------- /** * Where in statement prefixed with "or" * * @param string $field * @param mixed $val * @return Query_Builder */ public function or_where_in($field, $val=array()); // -------------------------------------------------------------------------- /** * WHERE NOT IN (FOO) clause * * @param string $field * @param mixed $val * @return Query_Builder */ public function where_not_in($field, $val=array()); // -------------------------------------------------------------------------- /** * OR WHERE NOT IN (FOO) clause * * @param string $field * @param mixed $val * @return Query_Builder */ public function or_where_not_in($field, $val=array()); // -------------------------------------------------------------------------- // ! Other Query Modifier methods // -------------------------------------------------------------------------- /** * Sets values for inserts / updates / deletes * * @param mixed $key * @param mixed $val * @return Query_Builder */ public function set($key, $val = NULL); // -------------------------------------------------------------------------- /** * Creates a join phrase in a compiled query * * @param string $table * @param string $condition * @param string $type * @return Query_Builder */ public function join($table, $condition, $type=''); // -------------------------------------------------------------------------- /** * Group the results by the selected field(s) * * @param mixed $field * @return Query_Builder */ public function group_by($field); // -------------------------------------------------------------------------- /** * Order the results by the selected field(s) * * @param string $field * @param string $type * @return Query_Builder */ public function order_by($field, $type=""); // -------------------------------------------------------------------------- /** * Set a limit on the current sql statement * * @param int $limit * @param int|bool $offset * @return Query_Builder */ public function limit($limit, $offset=FALSE); // -------------------------------------------------------------------------- // ! Query Grouping Methods // -------------------------------------------------------------------------- /** * Adds a paren to the current query for query grouping * * @return Query_Builder */ public function group_start(); // -------------------------------------------------------------------------- /** * Adds a paren to the current query for query grouping, * prefixed with 'OR' * * @return Query_Builder */ public function or_group_start(); // -------------------------------------------------------------------------- /** * Adds a paren to the current query for query grouping, * prefixed with 'OR NOT' * * @return Query_Builder */ public function or_not_group_start(); // -------------------------------------------------------------------------- /** * Ends a query group * * @return Query_Builder */ public function group_end(); // -------------------------------------------------------------------------- // ! Query execution methods // -------------------------------------------------------------------------- /** * Select and retrieve all records from the current table, and/or * execute current compiled query * * @param $table * @param int|bool $limit * @param int|bool $offset * @return \PDOStatement */ public function get($table='', $limit=FALSE, $offset=FALSE); // -------------------------------------------------------------------------- /** * Convience method for get() with a where clause * * @param string $table * @param array $where * @param int|bool $limit * @param int|bool $offset * @return \PDOStatement */ public function get_where($table, $where=array(), $limit=FALSE, $offset=FALSE); // -------------------------------------------------------------------------- /** * Retrieve the number of rows in the selected table * * @param string $table * @return int */ public function count_all($table); // -------------------------------------------------------------------------- /** * Retrieve the number of results for the generated query - used * in place of the get() method * * @param string $table * @return int */ public function count_all_results($table=''); // -------------------------------------------------------------------------- /** * Creates an insert clause, and executes it * * @param string $table * @param mixed $data * @return \PDOStatement */ public function insert($table, $data=array()); // -------------------------------------------------------------------------- /** * Creates and executes a batch insertion query * * @param string $table * @param array $data * @return \PDOStatement|null */ public function insert_batch($table, $data=array()); // -------------------------------------------------------------------------- /** * Creates an update clause, and executes it * * @param string $table * @param mixed $data * @return \PDOStatement */ public function update($table, $data=array()); // -------------------------------------------------------------------------- /** * Deletes data from a table * * @param string $table * @param mixed $where * @return \PDOStatement */ public function delete($table, $where=''); // -------------------------------------------------------------------------- // ! SQL Returning Methods // -------------------------------------------------------------------------- /** * Returns the generated 'select' sql query * * @param string $table * @param bool $reset * @return string */ public function get_compiled_select($table='', $reset=TRUE); // -------------------------------------------------------------------------- /** * Returns the generated 'insert' sql query * * @param string $table * @param bool $reset * @return string */ public function get_compiled_insert($table, $reset=TRUE); // -------------------------------------------------------------------------- /** * Returns the generated 'update' sql query * * @param string $table * @param bool $reset * @return string */ public function get_compiled_update($table='', $reset=TRUE); // -------------------------------------------------------------------------- /** * Returns the generated 'delete' sql query * * @param string $table * @param bool $reset * @return string */ public function get_compiled_delete($table="", $reset=TRUE); // -------------------------------------------------------------------------- // ! Miscellaneous Methods // -------------------------------------------------------------------------- /** * Clear out the class variables, so the next query can be run * * @return void */ public function reset_query(); } // End of query_builder_interface.php |
- Size: 3,267 Bytes - Last Modified: 2015-11-10T11:45:23-05:00
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
- Covered by 6 test(s):
- 64
- Covered by 6 test(s):
- 65666768697071727374757677
- Covered by 19 test(s):
- 78
- Covered by 19 test(s):
- 79
- Covered by 19 test(s):
- 808182
- Covered by 19 test(s):
- 83
- Covered by 19 test(s):
- 848586
- Covered by 19 test(s):
- 8788
- Covered by 19 test(s):
- 8990919293949596979899100101
- Covered by 16 test(s):
- 102
- Covered by 16 test(s):
- 103104105
- Covered by 16 test(s):
- 106107
- Covered by 16 test(s):
- 108
- Covered by 16 test(s):
- 109
- Covered by 16 test(s):
- 110
- Covered by 16 test(s):
- 111
- Covered by 16 test(s):
- 112113
- Covered by 16 test(s):
- 114115116117118119120121122123124125126
- Covered by 19 test(s):
- 127128
- Covered by 19 test(s):
- 129130
- Covered by 19 test(s):
- 131
- Covered by 19 test(s):
- 132133
- Covered by 19 test(s):
- 134135136137138
- Covered by 1 test(s):
-
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query; /** * Utility Class to parse sql clauses for properly escaping identifiers * * @package Query * @subpackage Query_Builder */ class QueryParser { /** * DB Driver * * @var DriverInterface */ private $db; /** * Regex patterns for various syntax components * * @var array */ private $match_patterns = array( 'function' => '([a-zA-Z0-9_]+\((.*?)\))', 'identifier' => '([a-zA-Z0-9_-]+\.?)+', 'operator' => '=|AND|&&?|~|\|\|?|\^|/|>=?|<=?|-|%|OR|\+|NOT|\!=?|<>|XOR' ); /** * Regex matches * * @var array */ public $matches = array( 'functions' => array(), 'identifiers' => array(), 'operators' => array(), 'combined' => array(), ); /** * Constructor/entry point into parser * * @param Driver\DriverInterface $db */ public function __construct(DriverInterface $db) { $this->db = $db; } // -------------------------------------------------------------------------- /** * Parser method for setting the parse string * * @param string $sql * @return array */ public function parse_join($sql) { // Get sql clause components preg_match_all('`'.$this->match_patterns['function'].'`', $sql, $this->matches['functions'], PREG_SET_ORDER); preg_match_all('`'.$this->match_patterns['identifier'].'`', $sql, $this->matches['identifiers'], PREG_SET_ORDER); preg_match_all('`'.$this->match_patterns['operator'].'`', $sql, $this->matches['operators'], PREG_SET_ORDER); // Get everything at once for ordering $full_pattern = '`'.$this->match_patterns['function'].'+|'.$this->match_patterns['identifier'].'|('.$this->match_patterns['operator'].')+`i'; preg_match_all($full_pattern, $sql, $this->matches['combined'], PREG_SET_ORDER); // Go through the matches, and get the most relevant matches $this->matches = array_map(array($this, 'filter_array'), $this->matches); return $this->matches; } // -------------------------------------------------------------------------- /** * Compiles a join condition after parsing * * @param string $condition * @return string */ public function compile_join($condition) { $parts = $this->parse_join($condition); $count = count($parts['identifiers']); // Go through and quote the identifiers for($i=0; $i <= $count; $i++) { if (in_array($parts['combined'][$i], $parts['identifiers']) && ! is_numeric($parts['combined'][$i])) { $parts['combined'][$i] = $this->db->quote_ident($parts['combined'][$i]); } } return implode('', $parts['combined']); } // -------------------------------------------------------------------------- /** * Returns a more useful match array * * @param array $array * @return array */ protected function filter_array($array) { $new_array = array(); foreach($array as $row) { $new_array[] = (is_array($row)) ? $row[0] : $row; } return $new_array; } } // End of QueryParser.php |
- Size: 2,344 Bytes - Last Modified: 2015-11-10T11:02:11-05:00
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
- Covered by 1 test(s):
-
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license * @package Query */ // -------------------------------------------------------------------------- namespace Query; /** * parent for database manipulation subclasses * * @package Query * @subpackage Drivers */ interface SQLInterface { /** * Get database specific sql for limit clause * * @param string $sql * @param int $limit * @param int|bool $offset * @return string */ public function limit($sql, $limit, $offset=FALSE); /** * Modify the query to get the query plan * * @param string $sql * @return string */ public function explain($sql); /** * Get the sql for random ordering * * @return string */ public function random(); /** * Returns sql to list other databases * * @return string */ public function db_list(); /** * Returns sql to list tables * * @return string */ public function table_list(); /** * Returns sql to list system tables * * @return string */ public function system_table_list(); /** * Returns sql to list views * * @return string */ public function view_list(); /** * Returns sql to list triggers * * @return string */ public function trigger_list(); /** * Return sql to list functions * * @return NULL */ public function function_list(); /** * Return sql to list stored procedures * * @return string */ public function procedure_list(); /** * Return sql to list sequences * * @return string */ public function sequence_list(); /** * Return sql to list database field types * * @return string|array */ public function type_list(); /** * Get information about the columns in the * specified table * * @param string $table * @return string */ public function column_list($table); /** * Get the list of foreign keys for the current * table * * @param string $table * @return array */ public function fk_list($table); /** * Get the list of indexes for the current table * * @param string $table * @return array */ public function index_list($table); } // End of sql_interface.php |
- Size: 4,708 Bytes - Last Modified: 2015-11-10T10:13:16-05:00
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 | <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @subpackage Core * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- /** * Global functions that don't really fit anywhere else */ // -------------------------------------------------------------------------- if ( ! function_exists('do_include')) { /** * Bulk directory loading workaround for use * with array_map and glob * * @param string $path * @return void */ function do_include($path) { require_once($path); } } // -------------------------------------------------------------------------- if ( ! function_exists('mb_trim')) { /** * Multibyte-safe trim function * * @param string $string * @return string */ function mb_trim($string) { return preg_replace("/(^\s+)|(\s+$)/us", "", $string); } } // -------------------------------------------------------------------------- if ( ! function_exists('db_filter')) { /** * Filter out db rows into one array * * @param array $array * @param mixed $index * @return array */ function db_filter($array, $index) { $new_array = array(); foreach($array as $a) { $new_array[] = $a[$index]; } return $new_array; } } // -------------------------------------------------------------------------- if ( ! function_exists('from_camel_case')) { /** * Create a snake_case string from camelCase * * @see http://stackoverflow.com/questions/1993721/how-to-convert-camelcase-to-camel-case * * @param string $input * @return string */ function from_camel_case($input) { preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches); $ret = $matches[0]; foreach ($ret as &$match) { $match = strtolower($match); } return implode('_', $ret); } } // -------------------------------------------------------------------------- if ( ! function_exists('array_zipper')) { /** * Zip a set of arrays together on common keys * * The $zipper_input array is an array of arrays indexed by their place in the output * array. * * @param array $zipper_input * @return array */ function array_zipper(Array $zipper_input) { $output = array(); foreach($zipper_input as $append_key => $values) { foreach($values as $index => $value) { if ( ! isset($output[$index])) { $output[$index] = array(); } $output[$index][$append_key] = $value; } } return $output; } } // -------------------------------------------------------------------------- if ( ! function_exists('array_pluck')) { /** * Get an array out of an multi-dimensional array based on a common * key * * @param array $array * @param string $key * @return array */ function array_pluck(Array $array, $key) { $output = array(); // No point iterating over an empty array if (empty($array)) return $array; foreach($array as $inner_array) { if (array_key_exists($key, $inner_array)) { $output[] = $inner_array[$key]; } } return $output; } } // -------------------------------------------------------------------------- if ( ! function_exists('regex_in_array')) { /** * Determine whether a value in the passed array matches the pattern * passed * * @param array $array * @param string $pattern * @return bool */ function regex_in_array(Array $array, $pattern) { if (empty($array)) return FALSE; foreach($array as $item) { if (is_scalar($item) && preg_match($pattern, $item)) { return TRUE; } } return FALSE; } } // -------------------------------------------------------------------------- if ( ! function_exists('Query')) { /** * Connection function * * Send an array or object as connection parameters to create a connection. If * the array or object has an 'alias' parameter, passing that string to this * function will return that connection. Passing no parameters returns the last * connection created. * * @param string|object|array $params * @return Query\Query_Builder|null */ function Query($params = '') { $cmanager = \Query\ConnectionManager::get_instance(); // If you are getting a previously created connection if (is_scalar($params)) { return $cmanager->get_connection($params); } elseif ( ! is_scalar($params) && ! is_null($params)) { $params_object = (object) $params; // Otherwise, return a new connection return $cmanager->connect($params_object); } } } // End of common.php |