1<?php 2 3namespace Doctrine\DBAL\Driver; 4 5use Doctrine\DBAL\ParameterType; 6 7/** 8 * Connection interface. 9 * Driver connections must implement this interface. 10 * 11 * This resembles (a subset of) the PDO interface. 12 */ 13interface Connection 14{ 15 /** 16 * Prepares a statement for execution and returns a Statement object. 17 * 18 * @param string $sql 19 * 20 * @return Statement 21 */ 22 public function prepare($sql); 23 24 /** 25 * Executes an SQL statement, returning a result set as a Statement object. 26 * 27 * @return Statement 28 */ 29 public function query(); 30 31 /** 32 * Quotes a string for use in a query. 33 * 34 * @param mixed $value 35 * @param int $type 36 * 37 * @return mixed 38 */ 39 public function quote($value, $type = ParameterType::STRING); 40 41 /** 42 * Executes an SQL statement and return the number of affected rows. 43 * 44 * @param string $sql 45 * 46 * @return int 47 */ 48 public function exec($sql); 49 50 /** 51 * Returns the ID of the last inserted row or sequence value. 52 * 53 * @param string|null $name 54 * 55 * @return string|int|false 56 */ 57 public function lastInsertId($name = null); 58 59 /** 60 * Initiates a transaction. 61 * 62 * @return bool TRUE on success or FALSE on failure. 63 */ 64 public function beginTransaction(); 65 66 /** 67 * Commits a transaction. 68 * 69 * @return bool TRUE on success or FALSE on failure. 70 */ 71 public function commit(); 72 73 /** 74 * Rolls back the current transaction, as initiated by beginTransaction(). 75 * 76 * @return bool TRUE on success or FALSE on failure. 77 */ 78 public function rollBack(); 79 80 /** 81 * Returns the error code associated with the last operation on the database handle. 82 * 83 * @deprecated The error information is available via exceptions. 84 * 85 * @return string|null The error code, or null if no operation has been run on the database handle. 86 */ 87 public function errorCode(); 88 89 /** 90 * Returns extended error information associated with the last operation on the database handle. 91 * 92 * @deprecated The error information is available via exceptions. 93 * 94 * @return mixed[] 95 */ 96 public function errorInfo(); 97} 98