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