Connection.php 2.08 KB
Newer Older
romanb's avatar
romanb committed
1 2
<?php

3 4
namespace Doctrine\DBAL\Driver;

5 6
use Doctrine\DBAL\ParameterType;

romanb's avatar
romanb committed
7 8
/**
 * Connection interface.
9
 * Driver connections must implement this interface.
romanb's avatar
romanb committed
10
 *
11
 * This resembles (a subset of) the PDO interface.
romanb's avatar
romanb committed
12
 */
13
interface Connection
romanb's avatar
romanb committed
14
{
Benjamin Morel's avatar
Benjamin Morel committed
15 16 17 18 19
    /**
     * Prepares a statement for execution and returns a Statement object.
     *
     * @param string $prepareString
     *
20
     * @return Statement
Benjamin Morel's avatar
Benjamin Morel committed
21
     */
22
    public function prepare($prepareString);
Benjamin Morel's avatar
Benjamin Morel committed
23 24 25 26

    /**
     * Executes an SQL statement, returning a result set as a Statement object.
     *
27
     * @return Statement
Benjamin Morel's avatar
Benjamin Morel committed
28
     */
29
    public function query();
Benjamin Morel's avatar
Benjamin Morel committed
30 31 32 33

    /**
     * Quotes a string for use in a query.
     *
34 35
     * @param mixed $input
     * @param int   $type
Benjamin Morel's avatar
Benjamin Morel committed
36
     *
37
     * @return mixed
Benjamin Morel's avatar
Benjamin Morel committed
38
     */
39
    public function quote($input, $type = ParameterType::STRING);
Benjamin Morel's avatar
Benjamin Morel committed
40 41 42 43 44 45

    /**
     * Executes an SQL statement and return the number of affected rows.
     *
     * @param string $statement
     *
46
     * @return int
Benjamin Morel's avatar
Benjamin Morel committed
47
     */
48
    public function exec($statement);
Benjamin Morel's avatar
Benjamin Morel committed
49 50 51 52 53 54 55 56

    /**
     * Returns the ID of the last inserted row or sequence value.
     *
     * @param string|null $name
     *
     * @return string
     */
57
    public function lastInsertId($name = null);
Benjamin Morel's avatar
Benjamin Morel committed
58 59 60 61

    /**
     * Initiates a transaction.
     *
62
     * @return bool TRUE on success or FALSE on failure.
Benjamin Morel's avatar
Benjamin Morel committed
63
     */
64
    public function beginTransaction();
Benjamin Morel's avatar
Benjamin Morel committed
65 66 67 68

    /**
     * Commits a transaction.
     *
69
     * @return bool TRUE on success or FALSE on failure.
Benjamin Morel's avatar
Benjamin Morel committed
70
     */
71
    public function commit();
Benjamin Morel's avatar
Benjamin Morel committed
72 73 74 75

    /**
     * Rolls back the current transaction, as initiated by beginTransaction().
     *
76
     * @return bool TRUE on success or FALSE on failure.
Benjamin Morel's avatar
Benjamin Morel committed
77
     */
78
    public function rollBack();
Benjamin Morel's avatar
Benjamin Morel committed
79 80 81 82 83 84

    /**
     * Returns the error code associated with the last operation on the database handle.
     *
     * @return string|null The error code, or null if no operation has been run on the database handle.
     */
85
    public function errorCode();
Benjamin Morel's avatar
Benjamin Morel committed
86 87 88 89

    /**
     * Returns extended error information associated with the last operation on the database handle.
     *
90
     * @return mixed[]
Benjamin Morel's avatar
Benjamin Morel committed
91
     */
92
    public function errorInfo();
Benjamin Eberlei's avatar
Benjamin Eberlei committed
93
}