Statement.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. * Statement interface.
  22. * Drivers must implement this interface.
  23. *
  24. * This resembles (a subset of) the PDOStatement interface.
  25. *
  26. * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
  27. * @author Roman Borschel <roman@code-factory.org>
  28. * @link www.doctrine-project.org
  29. * @since 2.0
  30. */
  31. interface Statement extends ResultStatement
  32. {
  33. /**
  34. * Binds a value to a corresponding named (not supported by mysqli driver, see comment below) or positional
  35. * placeholder in the SQL statement that was used to prepare the statement.
  36. *
  37. * As mentioned above, the named parameters are not natively supported by the mysqli driver, use executeQuery(),
  38. * fetchAll(), fetchArray(), fetchColumn(), fetchAssoc() methods to have the named parameter emulated by doctrine.
  39. *
  40. * @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
  41. * this will be a parameter name of the form :name. For a prepared statement
  42. * using question mark placeholders, this will be the 1-indexed position of the parameter.
  43. * @param mixed $value The value to bind to the parameter.
  44. * @param integer $type Explicit data type for the parameter using the PDO::PARAM_* constants.
  45. *
  46. * @return boolean TRUE on success or FALSE on failure.
  47. */
  48. function bindValue($param, $value, $type = null);
  49. /**
  50. * Binds a PHP variable to a corresponding named (not supported by mysqli driver, see comment below) or question
  51. * mark placeholder in the SQL statement that was use to prepare the statement. Unlike PDOStatement->bindValue(),
  52. * the variable is bound as a reference and will only be evaluated at the time
  53. * that PDOStatement->execute() is called.
  54. *
  55. * As mentioned above, the named parameters are not natively supported by the mysqli driver, use executeQuery(),
  56. * fetchAll(), fetchArray(), fetchColumn(), fetchAssoc() methods to have the named parameter emulated by doctrine.
  57. *
  58. * Most parameters are input parameters, that is, parameters that are
  59. * used in a read-only fashion to build up the query. Some drivers support the invocation
  60. * of stored procedures that return data as output parameters, and some also as input/output
  61. * parameters that both send in data and are updated to receive it.
  62. *
  63. * @param mixed $column Parameter identifier. For a prepared statement using named placeholders,
  64. * this will be a parameter name of the form :name. For a prepared statement using
  65. * question mark placeholders, this will be the 1-indexed position of the parameter.
  66. * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
  67. * @param integer|null $type Explicit data type for the parameter using the PDO::PARAM_* constants. To return
  68. * an INOUT parameter from a stored procedure, use the bitwise OR operator to set the
  69. * PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
  70. * @param integer|null $length You must specify maxlength when using an OUT bind
  71. * so that PHP allocates enough memory to hold the returned value.
  72. *
  73. * @return boolean TRUE on success or FALSE on failure.
  74. */
  75. function bindParam($column, &$variable, $type = null, $length = null);
  76. /**
  77. * Fetches the SQLSTATE associated with the last operation on the statement handle.
  78. *
  79. * @see Doctrine_Adapter_Interface::errorCode()
  80. *
  81. * @return string The error code string.
  82. */
  83. function errorCode();
  84. /**
  85. * Fetches extended error information associated with the last operation on the statement handle.
  86. *
  87. * @see Doctrine_Adapter_Interface::errorInfo()
  88. *
  89. * @return array The error info array.
  90. */
  91. function errorInfo();
  92. /**
  93. * Executes a prepared statement
  94. *
  95. * If the prepared statement included parameter markers, you must either:
  96. * call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
  97. * bound variables pass their value as input and receive the output value,
  98. * if any, of their associated parameter markers or pass an array of input-only
  99. * parameter values.
  100. *
  101. *
  102. * @param array|null $params An array of values with as many elements as there are
  103. * bound parameters in the SQL statement being executed.
  104. *
  105. * @return boolean TRUE on success or FALSE on failure.
  106. */
  107. function execute($params = null);
  108. /**
  109. * Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
  110. * executed by the corresponding object.
  111. *
  112. * If the last SQL statement executed by the associated Statement object was a SELECT statement,
  113. * some databases may return the number of rows returned by that statement. However,
  114. * this behaviour is not guaranteed for all databases and should not be
  115. * relied on for portable applications.
  116. *
  117. * @return integer The number of rows.
  118. */
  119. function rowCount();
  120. }