2016-10-12 22:12:25 -04:00
|
|
|
<?php declare(strict_types=1);
|
2012-04-10 14:06:34 -04:00
|
|
|
/**
|
|
|
|
* Query
|
|
|
|
*
|
2016-09-07 13:17:17 -04:00
|
|
|
* SQL Query Builder / Database Abstraction Layer
|
2012-04-10 14:06:34 -04:00
|
|
|
*
|
2019-12-11 16:49:42 -05:00
|
|
|
* PHP version 7.2
|
2016-09-07 13:17:17 -04:00
|
|
|
*
|
|
|
|
* @package Query
|
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
2019-12-11 16:49:42 -05:00
|
|
|
* @copyright 2012 - 2019 Timothy J. Warren
|
2016-09-07 13:17:17 -04:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
2019-12-11 16:49:42 -05:00
|
|
|
* @link https://git.timshomepage.net/aviat/Query
|
|
|
|
* @version 3.0.0
|
2012-04-10 14:06:34 -04:00
|
|
|
*/
|
2016-09-07 17:39:19 -04:00
|
|
|
namespace Query\Drivers;
|
2014-04-02 17:08:50 -04:00
|
|
|
|
2012-04-10 14:06:34 -04:00
|
|
|
/**
|
2018-01-24 15:03:41 -05:00
|
|
|
* Interface for database-specific syntax subclasses
|
2012-04-10 14:06:34 -04:00
|
|
|
*/
|
2015-11-10 11:10:15 -05:00
|
|
|
interface SQLInterface {
|
2012-04-10 14:06:34 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get database specific sql for limit clause
|
|
|
|
*
|
|
|
|
* @param string $sql
|
2012-04-19 11:42:50 -04:00
|
|
|
* @param int $limit
|
2014-04-22 14:02:54 -04:00
|
|
|
* @param int|bool $offset
|
2012-04-10 14:06:34 -04:00
|
|
|
* @return string
|
|
|
|
*/
|
2018-01-24 13:14:03 -05:00
|
|
|
public function limit(string $sql, int $limit, $offset=FALSE): string;
|
2014-03-26 21:33:58 -04:00
|
|
|
|
2014-02-04 20:59:30 -05:00
|
|
|
/**
|
|
|
|
* Modify the query to get the query plan
|
|
|
|
*
|
|
|
|
* @param string $sql
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-01-24 13:14:03 -05:00
|
|
|
public function explain(string $sql): string;
|
2012-04-10 14:06:34 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the sql for random ordering
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-01-24 13:14:03 -05:00
|
|
|
public function random(): string;
|
2014-03-26 21:33:58 -04:00
|
|
|
|
2012-04-10 14:06:34 -04:00
|
|
|
/**
|
|
|
|
* Returns sql to list other databases
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-01-24 13:14:03 -05:00
|
|
|
public function dbList(): string;
|
2012-04-10 14:06:34 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns sql to list tables
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-01-24 13:14:03 -05:00
|
|
|
public function tableList(): string;
|
2012-04-10 14:06:34 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns sql to list system tables
|
|
|
|
*
|
2018-01-24 13:14:03 -05:00
|
|
|
* @return string|array
|
2012-04-10 14:06:34 -04:00
|
|
|
*/
|
2016-10-13 21:55:23 -04:00
|
|
|
public function systemTableList();
|
2012-04-10 14:06:34 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns sql to list views
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-01-24 13:14:03 -05:00
|
|
|
public function viewList(): string;
|
2012-04-10 14:06:34 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns sql to list triggers
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-01-24 13:14:03 -05:00
|
|
|
public function triggerList(): ?string;
|
2012-04-10 14:06:34 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return sql to list functions
|
|
|
|
*
|
2018-01-24 13:14:03 -05:00
|
|
|
* @return string
|
2012-04-10 14:06:34 -04:00
|
|
|
*/
|
2018-01-24 13:14:03 -05:00
|
|
|
public function functionList(): ?string;
|
2012-04-10 14:06:34 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return sql to list stored procedures
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-01-24 13:14:03 -05:00
|
|
|
public function procedureList(): ?string;
|
2012-04-10 14:06:34 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return sql to list sequences
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-01-24 13:14:03 -05:00
|
|
|
public function sequenceList(): ?string;
|
2014-03-26 21:33:58 -04:00
|
|
|
|
2012-05-07 16:05:51 -04:00
|
|
|
/**
|
|
|
|
* Return sql to list database field types
|
|
|
|
*
|
2014-04-02 11:02:18 -04:00
|
|
|
* @return string|array
|
2012-05-07 16:05:51 -04:00
|
|
|
*/
|
2016-10-13 21:55:23 -04:00
|
|
|
public function typeList();
|
2014-03-26 21:33:58 -04:00
|
|
|
|
2012-05-09 13:54:38 -04:00
|
|
|
/**
|
2014-03-26 21:33:58 -04:00
|
|
|
* Get information about the columns in the
|
2012-05-09 13:54:38 -04:00
|
|
|
* specified table
|
|
|
|
*
|
2014-02-18 15:18:01 -05:00
|
|
|
* @param string $table
|
2012-05-09 13:54:38 -04:00
|
|
|
* @return string
|
|
|
|
*/
|
2018-01-24 13:14:03 -05:00
|
|
|
public function columnList(string $table): string;
|
2013-05-01 15:59:23 -04:00
|
|
|
|
2014-04-07 16:49:49 -04:00
|
|
|
/**
|
|
|
|
* Get the list of foreign keys for the current
|
|
|
|
* table
|
|
|
|
*
|
2014-04-15 16:15:08 -04:00
|
|
|
* @param string $table
|
2018-01-24 13:14:03 -05:00
|
|
|
* @return string
|
2014-04-07 16:49:49 -04:00
|
|
|
*/
|
2018-01-24 13:14:03 -05:00
|
|
|
public function fkList(string $table): string;
|
2014-04-07 16:49:49 -04:00
|
|
|
|
2014-04-08 14:26:28 -04:00
|
|
|
/**
|
|
|
|
* Get the list of indexes for the current table
|
|
|
|
*
|
|
|
|
* @param string $table
|
2018-01-24 13:14:03 -05:00
|
|
|
* @return string
|
2014-04-08 14:26:28 -04:00
|
|
|
*/
|
2018-01-24 13:14:03 -05:00
|
|
|
public function indexList(string $table): string;
|
2016-10-13 21:55:23 -04:00
|
|
|
}
|