Statement.php 4.9 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
     *                           constants.
53 54 55 56
     * @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.
57
     */
58
    public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null);
59 60

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

    /**
Benjamin Morel's avatar
Benjamin Morel committed
70
     * Fetches extended error information associated with the last operation on the statement handle.
71
     *
72
     * @return mixed[] The error info array.
73
     */
74
    public function errorInfo();
75 76 77 78 79 80 81 82

    /**
     * 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
83 84
     * parameter values.
     *
85 86
     * @param mixed[]|null $params An array of values with as many elements as there are
     *                             bound parameters in the SQL statement being executed.
87
     *
88
     * @return bool TRUE on success or FALSE on failure.
89
     */
90
    public function execute($params = null);
91 92

    /**
Benjamin Morel's avatar
Benjamin Morel committed
93
     * Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
94 95
     * executed by the corresponding object.
     *
96 97 98
     * 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
99 100
     * relied on for portable applications.
     *
101
     * @return int The number of rows.
102
     */
103
    public function rowCount() : int;
Benjamin Eberlei's avatar
Benjamin Eberlei committed
104
}