Statement.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. namespace Doctrine\DBAL\Driver;
  3. use Doctrine\DBAL\ParameterType;
  4. /**
  5. * Statement interface.
  6. * Drivers must implement this interface.
  7. *
  8. * This resembles (a subset of) the PDOStatement interface.
  9. */
  10. interface Statement extends ResultStatement
  11. {
  12. /**
  13. * Binds a value to a corresponding named (not supported by mysqli driver, see comment below) or positional
  14. * placeholder in the SQL statement that was used to prepare the statement.
  15. *
  16. * As mentioned above, the named parameters are not natively supported by the mysqli driver, use executeQuery(),
  17. * fetchAll(), fetchArray(), fetchColumn(), fetchAssoc() methods to have the named parameter emulated by doctrine.
  18. *
  19. * @param int|string $param Parameter identifier. For a prepared statement using named placeholders,
  20. * this will be a parameter name of the form :name. For a prepared statement
  21. * using question mark placeholders, this will be the 1-indexed position of the parameter.
  22. * @param mixed $value The value to bind to the parameter.
  23. * @param int $type Explicit data type for the parameter using the {@link ParameterType}
  24. * constants.
  25. *
  26. * @return bool TRUE on success or FALSE on failure.
  27. */
  28. public function bindValue($param, $value, $type = ParameterType::STRING);
  29. /**
  30. * Binds a PHP variable to a corresponding named (not supported by mysqli driver, see comment below) or question
  31. * mark placeholder in the SQL statement that was use to prepare the statement. Unlike PDOStatement->bindValue(),
  32. * the variable is bound as a reference and will only be evaluated at the time
  33. * that PDOStatement->execute() is called.
  34. *
  35. * As mentioned above, the named parameters are not natively supported by the mysqli driver, use executeQuery(),
  36. * fetchAll(), fetchArray(), fetchColumn(), fetchAssoc() methods to have the named parameter emulated by doctrine.
  37. *
  38. * Most parameters are input parameters, that is, parameters that are
  39. * used in a read-only fashion to build up the query. Some drivers support the invocation
  40. * of stored procedures that return data as output parameters, and some also as input/output
  41. * parameters that both send in data and are updated to receive it.
  42. *
  43. * @param int|string $param Parameter identifier. For a prepared statement using named placeholders,
  44. * this will be a parameter name of the form :name. For a prepared statement using
  45. * question mark placeholders, this will be the 1-indexed position of the parameter.
  46. * @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
  47. * @param int $type Explicit data type for the parameter using the {@link ParameterType}
  48. * constants. To return an INOUT parameter from a stored procedure, use the bitwise
  49. * OR operator to set the PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
  50. * @param int|null $length You must specify maxlength when using an OUT bind
  51. * so that PHP allocates enough memory to hold the returned value.
  52. *
  53. * @return bool TRUE on success or FALSE on failure.
  54. */
  55. public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null);
  56. /**
  57. * Fetches the SQLSTATE associated with the last operation on the statement handle.
  58. *
  59. * @deprecated The error information is available via exceptions.
  60. *
  61. * @see Doctrine_Adapter_Interface::errorCode()
  62. *
  63. * @return string|int|bool The error code string.
  64. */
  65. public function errorCode();
  66. /**
  67. * Fetches extended error information associated with the last operation on the statement handle.
  68. *
  69. * @deprecated The error information is available via exceptions.
  70. *
  71. * @return mixed[] The error info array.
  72. */
  73. public function errorInfo();
  74. /**
  75. * Executes a prepared statement
  76. *
  77. * If the prepared statement included parameter markers, you must either:
  78. * call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
  79. * bound variables pass their value as input and receive the output value,
  80. * if any, of their associated parameter markers or pass an array of input-only
  81. * parameter values.
  82. *
  83. * @param mixed[]|null $params An array of values with as many elements as there are
  84. * bound parameters in the SQL statement being executed.
  85. *
  86. * @return bool TRUE on success or FALSE on failure.
  87. */
  88. public function execute($params = null);
  89. /**
  90. * Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
  91. * executed by the corresponding object.
  92. *
  93. * If the last SQL statement executed by the associated Statement object was a SELECT statement,
  94. * some databases may return the number of rows returned by that statement. However,
  95. * this behaviour is not guaranteed for all databases and should not be
  96. * relied on for portable applications.
  97. *
  98. * @return int The number of rows.
  99. */
  100. public function rowCount();
  101. }