ResultStatement.php 5.56 KB
Newer Older
1 2 3 4
<?php

namespace Doctrine\DBAL\Driver;

5 6 7
use PDO;
use Traversable;

8 9 10
/**
 * Interface for the reading part of a prepare statement only.
 */
11
interface ResultStatement extends Traversable
12 13 14 15
{
    /**
     * Closes the cursor, enabling the statement to be executed again.
     *
16 17
     * @deprecated Use Result::free() instead.
     *
18
     * @return bool TRUE on success or FALSE on failure.
19
     */
Benjamin Morel's avatar
Benjamin Morel committed
20
    public function closeCursor();
21 22 23 24

    /**
     * Returns the number of columns in the result set
     *
25
     * @return int The number of columns in the result set represented
Benjamin Morel's avatar
Benjamin Morel committed
26 27
     *                 by the PDOStatement object. If there is no result set,
     *                 this method should return 0.
28
     */
Benjamin Morel's avatar
Benjamin Morel committed
29
    public function columnCount();
30

31
    /**
Benjamin Morel's avatar
Benjamin Morel committed
32
     * Sets the fetch mode to use while iterating this statement.
33
     *
34 35
     * @deprecated Use one of the fetch- or iterate-related methods.
     *
36
     * @param int   $fetchMode The fetch mode must be one of the {@link \Doctrine\DBAL\FetchMode} constants.
37 38
     * @param mixed $arg2
     * @param mixed $arg3
Benjamin Morel's avatar
Benjamin Morel committed
39
     *
40
     * @return bool
41
     */
Benjamin Morel's avatar
Benjamin Morel committed
42
    public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null);
43

44
    /**
Steve Müller's avatar
Steve Müller committed
45
     * Returns the next row of a result set.
Benjamin Morel's avatar
Benjamin Morel committed
46
     *
47 48
     * @deprecated Use fetchNumeric(), fetchAssociative() or fetchOne() instead.
     *
49
     * @param int|null $fetchMode         Controls how the next row will be returned to the caller.
50 51
     *                                    The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants,
     *                                    defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
     * @param int      $cursorOrientation For a ResultStatement object representing a scrollable cursor,
     *                                    this value determines which row will be returned to the caller.
     *                                    This value must be one of the \PDO::FETCH_ORI_* constants,
     *                                    defaulting to \PDO::FETCH_ORI_NEXT. To request a scrollable
     *                                    cursor for your ResultStatement object, you must set the \PDO::ATTR_CURSOR
     *                                    attribute to \PDO::CURSOR_SCROLL when you prepare the SQL statement with
     *                                    \PDO::prepare().
     * @param int      $cursorOffset      For a ResultStatement object representing a scrollable cursor for which the
     *                                    cursorOrientation parameter is set to \PDO::FETCH_ORI_ABS, this value
     *                                    specifies the absolute number of the row in the result set that shall be
     *                                    fetched.
     *                                    For a ResultStatement object representing a scrollable cursor for which the
     *                                    cursorOrientation parameter is set to \PDO::FETCH_ORI_REL, this value
     *                                    specifies the row to fetch relative to the cursor position before
     *                                    ResultStatement::fetch() was called.
Steve Müller's avatar
Steve Müller committed
67 68 69
     *
     * @return mixed The return value of this method on success depends on the fetch mode. In all cases, FALSE is
     *               returned on failure.
70
     */
71
    public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0);
72 73

    /**
Benjamin Morel's avatar
Benjamin Morel committed
74
     * Returns an array containing all of the result set rows.
75
     *
76
     * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead.
77
     *
78 79 80 81 82 83 84 85 86 87 88 89 90 91
     * @param int|null     $fetchMode     Controls how the next row will be returned to the caller.
     *                                    The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants,
     *                                    defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
     * @param int|null     $fetchArgument This argument has a different meaning depending on the value of the $fetchMode parameter:
     *                                    * {@link \Doctrine\DBAL\FetchMode::COLUMN}:
     *                                      Returns the indicated 0-indexed column.
     *                                    * {@link \Doctrine\DBAL\FetchMode::CUSTOM_OBJECT}:
     *                                      Returns instances of the specified class, mapping the columns of each row
     *                                      to named properties in the class.
     *                                    * \PDO::FETCH_FUNC: Returns the results of calling the specified function, using each row's
     *                                      columns as parameters in the call.
     * @param mixed[]|null $ctorArgs      Controls how the next row will be returned to the caller.
     *                                    The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants,
     *                                    defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
92
     *
93
     * @return mixed[]
94
     */
95
    public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null);
96 97

    /**
Benjamin Morel's avatar
Benjamin Morel committed
98
     * Returns a single column from the next row of a result set or FALSE if there are no more rows.
99
     *
100 101
     * @deprecated Use fetchOne() instead.
     *
102
     * @param int $columnIndex 0-indexed number of the column you wish to retrieve from the row.
103
     *                         If no value is supplied, fetches the first column.
104
     *
105
     * @return mixed|false A single column in the next row of a result set, or FALSE if there are no more rows.
106
     */
Benjamin Morel's avatar
Benjamin Morel committed
107
    public function fetchColumn($columnIndex = 0);
108
}