Connection.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /*
  3. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  4. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  5. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  6. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  7. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  8. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  9. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  10. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  11. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  12. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  13. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. *
  15. * This software consists of voluntary contributions made by many individuals
  16. * and is licensed under the MIT license. For more information, see
  17. * <http://www.doctrine-project.org>.
  18. */
  19. namespace Doctrine\DBAL\Driver;
  20. /**
  21. * Connection interface.
  22. * Driver connections must implement this interface.
  23. *
  24. * This resembles (a subset of) the PDO interface.
  25. *
  26. * @since 2.0
  27. */
  28. interface Connection
  29. {
  30. /**
  31. * Prepares a statement for execution and returns a Statement object.
  32. *
  33. * @param string $prepareString
  34. *
  35. * @return \Doctrine\DBAL\Driver\Statement
  36. */
  37. function prepare($prepareString);
  38. /**
  39. * Executes an SQL statement, returning a result set as a Statement object.
  40. *
  41. * @return \Doctrine\DBAL\Driver\Statement
  42. */
  43. function query();
  44. /**
  45. * Quotes a string for use in a query.
  46. *
  47. * @param string $input
  48. * @param integer $type
  49. *
  50. * @return string
  51. */
  52. function quote($input, $type=\PDO::PARAM_STR);
  53. /**
  54. * Executes an SQL statement and return the number of affected rows.
  55. *
  56. * @param string $statement
  57. *
  58. * @return integer
  59. */
  60. function exec($statement);
  61. /**
  62. * Returns the ID of the last inserted row or sequence value.
  63. *
  64. * @param string|null $name
  65. *
  66. * @return string
  67. */
  68. function lastInsertId($name = null);
  69. /**
  70. * Initiates a transaction.
  71. *
  72. * @return boolean TRUE on success or FALSE on failure.
  73. */
  74. function beginTransaction();
  75. /**
  76. * Commits a transaction.
  77. *
  78. * @return boolean TRUE on success or FALSE on failure.
  79. */
  80. function commit();
  81. /**
  82. * Rolls back the current transaction, as initiated by beginTransaction().
  83. *
  84. * @return boolean TRUE on success or FALSE on failure.
  85. */
  86. function rollBack();
  87. /**
  88. * Returns the error code associated with the last operation on the database handle.
  89. *
  90. * @return string|null The error code, or null if no operation has been run on the database handle.
  91. */
  92. function errorCode();
  93. /**
  94. * Returns extended error information associated with the last operation on the database handle.
  95. *
  96. * @return array
  97. */
  98. function errorInfo();
  99. }