2014-04-22 14:02:54 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Query
|
|
|
|
*
|
2016-09-07 13:17:17 -04:00
|
|
|
* SQL Query Builder / Database Abstraction Layer
|
2014-04-22 14:02:54 -04:00
|
|
|
*
|
2016-09-07 13:17:17 -04:00
|
|
|
* PHP version 5.4
|
|
|
|
*
|
|
|
|
* @package Query
|
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
|
|
|
* @copyright 2012 - 2015 Timothy J. Warren
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
|
|
* @link https://git.timshomepage.net/aviat4ion/Query
|
2014-04-22 14:02:54 -04:00
|
|
|
*/
|
|
|
|
|
2016-09-07 17:39:19 -04:00
|
|
|
namespace Query\Drivers;
|
2014-04-22 14:02:54 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* PDO Interface to implement for database drivers
|
|
|
|
*
|
|
|
|
* @package Query
|
|
|
|
* @subpackage Drivers
|
|
|
|
*/
|
2016-09-07 17:39:19 -04:00
|
|
|
interface DriverInterface extends PDOInterface {
|
2014-04-22 14:02:54 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor/Connection method
|
|
|
|
*
|
|
|
|
* @param string $dsn
|
|
|
|
* @param string $username
|
|
|
|
* @param string $password
|
|
|
|
* @param array $driver_options
|
|
|
|
*/
|
2016-09-07 13:10:03 -04:00
|
|
|
public function __construct($dsn, $username=NULL, $password=NULL, array $driver_options = []);
|
2014-04-22 14:02:54 -04:00
|
|
|
|
2014-04-24 14:50:53 -04:00
|
|
|
/**
|
|
|
|
* Simplifies prepared statements for database queries
|
|
|
|
*
|
|
|
|
* @param string $sql
|
|
|
|
* @param array $data
|
|
|
|
* @return \PDOStatement | FALSE
|
|
|
|
* @throws \InvalidArgumentException
|
|
|
|
*/
|
|
|
|
public function prepare_query($sql, $data);
|
|
|
|
|
2014-04-22 14:02:54 -04:00
|
|
|
/**
|
|
|
|
* Retrieve column information for the current database table
|
|
|
|
*
|
|
|
|
* @param string $table
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function get_columns($table);
|
|
|
|
|
2014-04-24 14:50:53 -04:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
2014-04-22 14:02:54 -04:00
|
|
|
/**
|
|
|
|
* 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();
|
|
|
|
|
2014-04-24 14:50:53 -04:00
|
|
|
/**
|
|
|
|
* Retrieves an array of non-user-created tables for
|
|
|
|
* the connection/database
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function get_system_tables();
|
|
|
|
|
2014-04-24 13:42:01 -04:00
|
|
|
/**
|
|
|
|
* Return list of dbs for the current connection, if possible
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function get_dbs();
|
|
|
|
|
2014-04-24 14:50:53 -04:00
|
|
|
/**
|
|
|
|
* 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();
|
|
|
|
|
2014-04-22 14:02:54 -04:00
|
|
|
/**
|
|
|
|
* Surrounds the string with the databases identifier escape characters
|
|
|
|
*
|
2015-07-30 13:13:12 -04:00
|
|
|
* @param string|array $ident
|
|
|
|
* @return string|array
|
2014-04-22 14:02:54 -04:00
|
|
|
*/
|
|
|
|
public function quote_ident($ident);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Quote database table name, and set prefix
|
|
|
|
*
|
2015-07-30 13:13:12 -04:00
|
|
|
* @param string|array $table
|
|
|
|
* @return string|array
|
2014-04-22 14:02:54 -04:00
|
|
|
*/
|
|
|
|
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);
|
2014-04-23 15:53:16 -04:00
|
|
|
|
|
|
|
|
2014-04-24 13:42:01 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
2014-04-24 14:50:53 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2016-09-07 13:10:03 -04:00
|
|
|
public function insert_batch($table, $data=[]);
|
2016-09-07 17:39:19 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a batch update, and executes it.
|
|
|
|
* Returns the number of affected rows
|
|
|
|
*
|
|
|
|
* @param string $table
|
|
|
|
* @param array|object $data
|
|
|
|
* @param string $where
|
|
|
|
* @return int|null
|
|
|
|
*/
|
|
|
|
public function update_batch($table, $data, $where);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the SQL class for the current driver
|
|
|
|
*
|
|
|
|
* @return \Query\Drivers\SQLInterface
|
|
|
|
*/
|
|
|
|
public function get_sql();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Util class for the current driver
|
|
|
|
*
|
|
|
|
* @return \Query\Drivers\AbstractUtil
|
|
|
|
*/
|
|
|
|
public function get_util();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the last query sql
|
|
|
|
*
|
|
|
|
* @param string $query_string
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function set_last_query($query_string);
|
2014-04-22 14:02:54 -04:00
|
|
|
}
|
2015-11-10 20:58:32 -05:00
|
|
|
// End of driver_interface.php
|