ResultStatement.php 5.19 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
     * @return bool TRUE on success or FALSE on failure.
17
     */
Benjamin Morel's avatar
Benjamin Morel committed
18
    public function closeCursor();
19 20 21 22

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

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

40
    /**
Steve Müller's avatar
Steve Müller committed
41
     * Returns the next row of a result set.
Benjamin Morel's avatar
Benjamin Morel committed
42
     *
43
     * @param int|null $fetchMode         Controls how the next row will be returned to the caller.
44 45
     *                                    The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants,
     *                                    defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
     * @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
61 62 63
     *
     * @return mixed The return value of this method on success depends on the fetch mode. In all cases, FALSE is
     *               returned on failure.
64
     */
65
    public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0);
66 67

    /**
Benjamin Morel's avatar
Benjamin Morel committed
68
     * Returns an array containing all of the result set rows.
69
     *
70 71 72 73 74 75 76 77 78 79 80 81 82 83
     * @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}.
84
     *
85
     * @return mixed[]
86
     */
87
    public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null);
88 89

    /**
Benjamin Morel's avatar
Benjamin Morel committed
90
     * Returns a single column from the next row of a result set or FALSE if there are no more rows.
91
     *
92
     * @param int $columnIndex 0-indexed number of the column you wish to retrieve from the row.
93
     *                         If no value is supplied, fetches the first column.
94
     *
95
     * @return mixed|false A single column in the next row of a result set, or FALSE if there are no more rows.
96
     */
Benjamin Morel's avatar
Benjamin Morel committed
97
    public function fetchColumn($columnIndex = 0);
98
}