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

Michael Moravec's avatar
Michael Moravec committed
3 4
declare(strict_types=1);

5 6
namespace Doctrine\DBAL\Driver;

7
use Doctrine\DBAL\DBALException;
8

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

    /**
     * Executes an SQL statement, returning a result set as a Statement object.
     *
25
     * @throws DBALException
Benjamin Morel's avatar
Benjamin Morel committed
26
     */
27
    public function query(string $sql) : ResultStatement;
Benjamin Morel's avatar
Benjamin Morel committed
28 29 30 31

    /**
     * Quotes a string for use in a query.
     */
32
    public function quote(string $input) : string;
Benjamin Morel's avatar
Benjamin Morel committed
33 34 35 36

    /**
     * Executes an SQL statement and return the number of affected rows.
     *
37
     * @throws DBALException
Benjamin Morel's avatar
Benjamin Morel committed
38
     */
39
    public function exec(string $statement) : int;
Benjamin Morel's avatar
Benjamin Morel committed
40 41 42 43

    /**
     * Returns the ID of the last inserted row or sequence value.
     */
44
    public function lastInsertId(?string $name = null) : string;
Benjamin Morel's avatar
Benjamin Morel committed
45 46 47 48

    /**
     * Initiates a transaction.
     *
49
     * @throws DriverException
Benjamin Morel's avatar
Benjamin Morel committed
50
     */
51
    public function beginTransaction() : void;
Benjamin Morel's avatar
Benjamin Morel committed
52 53 54 55

    /**
     * Commits a transaction.
     *
56
     * @throws DriverException
Benjamin Morel's avatar
Benjamin Morel committed
57
     */
58
    public function commit() : void;
Benjamin Morel's avatar
Benjamin Morel committed
59 60 61 62

    /**
     * Rolls back the current transaction, as initiated by beginTransaction().
     *
63
     * @throws DriverException
Benjamin Morel's avatar
Benjamin Morel committed
64
     */
65
    public function rollBack() : void;
Benjamin Eberlei's avatar
Benjamin Eberlei committed
66
}