Statement.php 5.08 KB
Newer Older
1 2 3 4
<?php

namespace Doctrine\DBAL\Driver;

5 6
use Doctrine\DBAL\ParameterType;

7 8 9
/**
 * Statement interface.
 * Drivers must implement this interface.
10
 *
11
 * This resembles (a subset of) the PDOStatement interface.
12
 */
13
interface Statement extends ResultStatement
14
{
15
    /**
16
     * Binds a value to a corresponding named (not supported by mysqli driver, see comment below) or positional
17 18
     * placeholder in the SQL statement that was used to prepare the statement.
     *
19 20 21
     * As mentioned above, the named parameters are not natively supported by the mysqli driver, use executeQuery(),
     * fetchAll(), fetchArray(), fetchColumn(), fetchAssoc() methods to have the named parameter emulated by doctrine.
     *
22 23 24 25
     * @param mixed $param Parameter identifier. For a prepared statement using named placeholders,
     *                     this will be a parameter name of the form :name. For a prepared statement
     *                     using question mark placeholders, this will be the 1-indexed position of the parameter.
     * @param mixed $value The value to bind to the parameter.
26 27
     * @param int   $type  Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType}
     *                     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 35 36 37 38 39 40 41 42 43

    /**
     * Binds a PHP variable to a corresponding named (not supported by mysqli driver, see comment below) or question
     * mark placeholder in the SQL statement that was use to prepare the statement. Unlike PDOStatement->bindValue(),
     * the variable is bound as a reference and will only be evaluated at the time
     * that PDOStatement->execute() is called.
     *
     * As mentioned above, the named parameters are not natively supported by the mysqli driver, use executeQuery(),
     * fetchAll(), fetchArray(), fetchColumn(), fetchAssoc() methods to have the named parameter emulated by doctrine.
     *
     * Most parameters are input parameters, that is, parameters that are
     * used in a read-only fashion to build up the query. Some drivers support the invocation
44 45 46
     * of stored procedures that return data as output parameters, and some also as input/output
     * parameters that both send in data and are updated to receive it.
     *
47 48 49 50
     * @param mixed    $column   Parameter identifier. For a prepared statement using named placeholders,
     *                           this will be a parameter name of the form :name. For a prepared statement using
     *                           question mark placeholders, this will be the 1-indexed position of the parameter.
     * @param mixed    $variable Name of the PHP variable to bind to the SQL statement parameter.
Sergei Morozov's avatar
Sergei Morozov committed
51
     * @param int      $type     Explicit data type for the parameter using the {@link \Doctrine\DBAL\ParameterType}
52 53
     *                           constants. To return an INOUT parameter from a stored procedure, use the bitwise
     *                           OR operator to set the PDO::PARAM_INPUT_OUTPUT bits for the data_type parameter.
54 55 56 57
     * @param int|null $length   You must specify maxlength when using an OUT bind
     *                           so that PHP allocates enough memory to hold the returned value.
     *
     * @return bool TRUE on success or FALSE on failure.
58
     */
59
    public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null);
60 61

    /**
Benjamin Morel's avatar
Benjamin Morel committed
62
     * Fetches the SQLSTATE associated with the last operation on the statement handle.
63 64
     *
     * @see Doctrine_Adapter_Interface::errorCode()
Benjamin Morel's avatar
Benjamin Morel committed
65
     *
66
     * @return string|int|bool The error code string.
67
     */
68
    public function errorCode();
69 70

    /**
Benjamin Morel's avatar
Benjamin Morel committed
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 79 80 81 82 83

    /**
     * Executes a prepared statement
     *
     * If the prepared statement included parameter markers, you must either:
     * call PDOStatement->bindParam() to bind PHP variables to the parameter markers:
     * bound variables pass their value as input and receive the output value,
     * if any, of their associated parameter markers or pass an array of input-only
Benjamin Morel's avatar
Benjamin Morel committed
84 85
     * parameter values.
     *
86 87
     * @param mixed[]|null $params An array of values with as many elements as there are
     *                             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

    /**
Benjamin Morel's avatar
Benjamin Morel committed
94
     * Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
95 96
     * executed by the corresponding object.
     *
97 98 99
     * If the last SQL statement executed by the associated Statement object was a SELECT statement,
     * some databases may return the number of rows returned by that statement. However,
     * this behaviour is not guaranteed for all databases and should not be
100 101
     * relied on for portable applications.
     *
102
     * @return int The number of rows.
103
     */
104
    public function rowCount();
Benjamin Eberlei's avatar
Benjamin Eberlei committed
105
}