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