Connection.php 2.2 KB

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