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:
<?php
/**
* MvcCore
*
* This source file is subject to the BSD 3 License
* For the full copyright and license information, please view
* the LICENSE.md file that are distributed with this source code.
*
* @copyright Copyright (c) 2016 Tom Flidr (https://github.com/mvccore)
* @license https://mvccore.github.io/docs/mvccore/5.0.0/LICENCE.md
*/
namespace MvcCore\Ext\Models\Db;
interface IConnection {
/**
* Return an array of available `\PDO` drivers.
* @return array
*/
public static function GetAvailableDrivers ();
/**
* Connect into database by given dsn, credentials and options or thrown an error.
* @param string $dsn
* @param string|NULL $username
* @param string|NULL $password
* @param array $options
* @throws \Throwable
*/
public function __construct ($dsn, $username = NULL, $password = NULL, array $options = []);
/**
* Prepares a statement for execution and returns a statement object.
* @param string|\string[] $sql
* @param int|string $connectionIndexOrName
* @return \MvcCore\Ext\Models\Db\Statement
*/
public function Prepare ($sql, $connectionIndexOrName = NULL);
/**
* Executes an SQL statement and returns a statement object.
* @param string|\string[] $sql
* @throws \Throwable
* @return \MvcCore\Ext\Models\Db\Statement
*/
public function Query ($sql, $connectionIndexOrName = NULL);
/**
* Execute an SQL statement and returns a reader object.
* @param string|\string[] $sql
* @throws \Throwable
* @return \MvcCore\Ext\Models\Db\Readers\Execution
*/
public function Execute ($sql, $connectionIndexOrName = NULL);
/**
* Returns the ID of the last inserted row or sequence value.
* @param string|NULL $sequenceName
* @param string|NULL $targetType
* @return int|float|string|NULL
*/
public function LastInsertId ($sequenceName = NULL, $targetType = NULL);
/**
* Quotes a string for use in a query.
* @param string $string
* @param int $paramType
* @return string
*/
public function Quote ($string , $paramType = \PDO::PARAM_STR);
/**
* Quote database identifier by provider specfic way,
* usually table or column name.
* @param string $identifierName
* @return string
*/
public function QuoteName ($identifierName);
/**
* Retrieve a `\PDO` database connection attribute.
* @param int $attribute
* @return mixed
*/
public function GetAttribute ($attribute);
/**
* Set a `\PDO` database connection attribute.
* @param int $attribute
* @param mixed $value
* @return bool
*/
public function SetAttribute ($attribute , $value);
/**
* Return database server version in "PHP-standardized" version number string.
* @return null|string
*/
public function GetVersion ();
/**
* Return `TRUE` for multi statements connection type.
* @return bool|null
*/
public function IsMutliStatements ();
/**
* Return internal `\PDO` database connection instance.
* @return \PDO
*/
public function GetProvider ();
/**
* Get `__construct()` function arguments values.
* @return array
*/
public function GetConfig ();
/**
* Checks if this connection is already inside transaction or not.
* @return bool
*/
public function InTransaction ();
/**
* Initiates a transaction.
* @param int $flags Transaction isolation, read/write mode and more, depends on database driver.
* @param string $name String without spaces to identify transaction in logs.
* @throws \PDOException|\RuntimeException
* @return bool
*/
public function BeginTransaction ($flags = 0, $name = NULL);
/**
* Commits a transaction.
* @param int $flags
* @throws \PDOException
* @return bool
*/
public function Commit ($flags = 0);
/**
* Rolls back a transaction.
* @param int $flags
* @throws \PDOException
* @return bool
*/
public function Rollback ($flags = 0);
}