Connection.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 $prepareString
  16. *
  17. * @return Statement
  18. */
  19. public function prepare($prepareString);
  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 $input
  30. * @param int $type
  31. *
  32. * @return mixed
  33. */
  34. public function quote($input, $type = ParameterType::STRING);
  35. /**
  36. * Executes an SQL statement and return the number of affected rows.
  37. *
  38. * @param string $statement
  39. *
  40. * @return int
  41. */
  42. public function exec($statement);
  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. * @return string|null The error code, or null if no operation has been run on the database handle.
  73. */
  74. public function errorCode();
  75. /**
  76. * Returns extended error information associated with the last operation on the database handle.
  77. *
  78. * @return mixed[]
  79. */
  80. public function errorInfo();
  81. }