Statement.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 mixed $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 \Doctrine\DBAL\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 mixed $column 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|null $type Explicit data type for the parameter using the {@link \Doctrine\DBAL\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($column, &$variable, $type = ParameterType::STRING, $length = null);
  56. /**
  57. * Fetches the SQLSTATE associated with the last operation on the statement handle.
  58. *
  59. * @see Doctrine_Adapter_Interface::errorCode()
  60. *
  61. * @return string|int|bool The error code string.
  62. */
  63. public function errorCode();
  64. /**
  65. * Fetches extended error information associated with the last operation on the statement handle.
  66. *
  67. * @return mixed[] The error info array.
  68. */
  69. public function errorInfo();
  70. /**
  71. * Executes a prepared statement
  72. *
  73. * If the prepared statement included parameter markers, you must either:
  74. * call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
  75. * bound variables pass their value as input and receive the output value,
  76. * if any, of their associated parameter markers or pass an array of input-only
  77. * parameter values.
  78. *
  79. * @param mixed[]|null $params An array of values with as many elements as there are
  80. * bound parameters in the SQL statement being executed.
  81. *
  82. * @return bool TRUE on success or FALSE on failure.
  83. */
  84. public function execute($params = null);
  85. /**
  86. * Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
  87. * executed by the corresponding object.
  88. *
  89. * If the last SQL statement executed by the associated Statement object was a SELECT statement,
  90. * some databases may return the number of rows returned by that statement. However,
  91. * this behaviour is not guaranteed for all databases and should not be
  92. * relied on for portable applications.
  93. *
  94. * @return int The number of rows.
  95. */
  96. public function rowCount();
  97. }