# phpDox - Source of DriverInterface.php

# Source of file DriverInterface.php

Size: 6,266 Bytes - Last Modified: 2020-04-23T17:38:36-04:00

## src/Drivers/DriverInterface.php

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286

    <?php declare(strict_types=1);

    /**

     * Query

     *

     * SQL Query Builder / Database Abstraction Layer

     *

     * PHP version 7.4

     *

     * @package     Query

     * @author      Timothy J. Warren <tim@timshomepage.net>

     * @copyright   2012 - 2020 Timothy J. Warren

     * @license     http://www.opensource.org/licenses/mit-license.html  MIT License

     * @link        https://git.timshomepage.net/aviat/Query

     * @version     3.0.0

     */

    namespace Query\Drivers;

    use InvalidArgumentException;

    use PDO;

    use PDOStatement;

    /**

     * PDO Interface to implement for database drivers

     *

     * @method beginTransaction(): bool

     * @method commit(): bool

     * @method errorCode(): string

     * @method errorInfo(): array

     * @method exec(string $statement): int

     * @method getAttribute(int $attribute)

     * @method inTransaction(): bool

     * @method lastInsertId(string $name = NULL): string

     * @method prepare(string $statement, array $driver_options = []): PDOStatement

     * @method query(string $statement): PDOStatement

     * @method quote(string $string, int $parameter_type = PDO::PARAM_STR): string

     * @method rollback(): bool

     * @method setAttribute(int $attribute, $value): bool

     */

    interface DriverInterface /* extends the interface of PDO */ {

    	/**

    	 * Constructor/Connection method

    	 *

    	 * @param string $dsn

    	 * @param string $username

    	 * @param string $password

    	 * @param array $driverOptions

    	 */

    	public function __construct(string $dsn, string $username=NULL, string $password=NULL, array $driverOptions = []);

    	/**

    	 * Simplifies prepared statements for database queries

    	 *

    	 * @param string $sql

    	 * @param array $data

    	 * @return PDOStatement|null

    	 * @throws InvalidArgumentException

    	 */

    	public function prepareQuery(string $sql, array $data): PDOStatement;

    	/**

    	 * Retrieve column information for the current database table

    	 *

    	 * @param string $table

    	 * @return array

    	 */

    	public function getColumns(string $table): ?array;

    	/**

    	 * Retrieve list of data types for the database

    	 *

    	 * @return array

    	 */

    	public function getTypes(): ?array;

    	/**

    	 * Retrieve indexes for the table

    	 *

    	 * @param string $table

    	 * @return array

    	 */

    	public function getIndexes(string $table): ?array;

    	/**

    	 * Retrieve foreign keys for the table

    	 *

    	 * @param string $table

    	 * @return array

    	 */

    	public function getFks(string $table): ?array;

    	/**

    	 * Return list of tables for the current database

    	 *

    	 * @return array

    	 */

    	public function getTables(): ?array;

    	/**

    	 * Retrieves an array of non-user-created tables for

    	 * the connection/database

    	 *

    	 * @return array

    	 */

    	public function getSystemTables(): ?array;

    	/**

    	 * Return schemas for databases that list them. Returns

    	 * database list if schemas are databases for the current driver.

    	 *

    	 * @return array

    	 */

    	public function getSchemas(): ?array;

    	/**

    	 * Return list of dbs for the current connection, if possible

    	 *

    	 * @return array

    	 */

    	public function getDbs(): ?array;

    	/**

    	 * Return list of views for the current database

    	 *

    	 * @return array

    	 */

    	public function getViews(): ?array;

    	/**

    	 * Return list of sequences for the current database, if they exist

    	 *

    	 * @return array

    	 */

    	public function getSequences(): ?array;

    	/**

    	 * Return list of functions for the current database

    	 *

    	 * @return array

    	 */

    	public function getFunctions(): ?array;

    	/**

    	 * Return list of stored procedures for the current database

    	 *

    	 * @return array

    	 */

    	public function getProcedures(): ?array;

    	/**

    	 * Return list of triggers for the current database

    	 *

    	 * @return array

    	 */

    	public function getTriggers(): ?array;

    	/**

    	 * Surrounds the string with the databases identifier escape characters

    	 *

    	 * @param string|array $ident

    	 * @return string|array

    	 */

    	public function quoteIdent($ident);

    	/**

    	 * Quote database table name, and set prefix

    	 *

    	 * @param string $table

    	 * @return string

    	 */

    	public function quoteTable(string $table): string;

    	/**

    	 * Create and execute a prepared statement with the provided parameters

    	 *

    	 * @param string $sql

    	 * @param array $params

    	 * @return PDOStatement

    	 */

    	public function prepareExecute(string $sql, array $params): PDOStatement;

    	/**

    	 * Method to simplify retrieving db results for meta-data queries

    	 *

    	 * @param string|array|null $query

    	 * @param bool $filteredIndex

    	 * @return array

    	 */

    	public function driverQuery($query, $filteredIndex=TRUE): ?array;

    	/**

    	 * Returns number of rows affected by an INSERT, UPDATE, DELETE type query

    	 *

    	 * @return int

    	 */

    	public function affectedRows(): int;

    	/**

    	 * 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 numRows(): ?int;

    	/**

    	 * Prefixes a table if it is not already prefixed

    	 *

    	 * @param string $table

    	 * @return string

    	 */

    	public function prefixTable(string $table): string;

    	/**

    	 * Create sql for batch insert

    	 *

    	 * @param string $table

    	 * @param array $data

    	 * @return array

    	 */

    	public function insertBatch(string $table, array $data=[]): array;

    	/**

    	 * Creates a batch update, and executes it.

    	 * Returns the number of affected rows

    	 *

    	 * @param string $table

    	 * @param array $data

    	 * @param string $where

    	 * @return array

    	 */

    	public function updateBatch(string $table, array $data, string $where): array;

    	/**

    	 * Empty the passed table

    	 *

    	 * @param string $table

    	 * @return PDOStatement

    	 */

    	public function truncate(string $table): PDOStatement;

    	/**

    	 * Get the SQL class for the current driver

    	 *

    	 * @return SQLInterface

    	 */

    	public function getSql(): SQLInterface;

    	/**

    	 * Get the Util class for the current driver

    	 *

    	 * @return AbstractUtil

    	 */

    	public function getUtil(): AbstractUtil;

    	/**

    	 * Get the version of the database engine

    	 *

    	 * @return string

    	 */

    	public function getVersion(): string;

    	/**

    	 * Get the last sql query executed

    	 *

    	 * @return string

    	 */

    	public function getLastQuery(): string;

    	/**

    	 * Set the last query sql

    	 *

    	 * @param string $queryString

    	 * @return void

    	 */

    	public function setLastQuery(string $queryString): void;

    	/**

    	 * Set the common table name prefix

    	 *

    	 * @param string $prefix

    	 * @return void

    	 */

    	public function setTablePrefix(string $prefix): void;

    }