Connection.php 3 KB
Newer Older
romanb's avatar
romanb committed
1
<?php
2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
Benjamin Eberlei's avatar
Benjamin Eberlei committed
16
 * and is licensed under the MIT license. For more information, see
17 18
 * <http://www.doctrine-project.org>.
 */
romanb's avatar
romanb committed
19

20 21
namespace Doctrine\DBAL\Driver;

romanb's avatar
romanb committed
22 23
/**
 * Connection interface.
24
 * Driver connections must implement this interface.
romanb's avatar
romanb committed
25
 *
26
 * This resembles (a subset of) the PDO interface.
27
 *
romanb's avatar
romanb committed
28 29
 * @since 2.0
 */
30
interface Connection
romanb's avatar
romanb committed
31
{
Benjamin Morel's avatar
Benjamin Morel committed
32 33 34 35 36 37 38
    /**
     * Prepares a statement for execution and returns a Statement object.
     *
     * @param string $prepareString
     *
     * @return \Doctrine\DBAL\Driver\Statement
     */
39
    function prepare($prepareString);
Benjamin Morel's avatar
Benjamin Morel committed
40 41 42 43 44 45

    /**
     * Executes an SQL statement, returning a result set as a Statement object.
     *
     * @return \Doctrine\DBAL\Driver\Statement
     */
46
    function query();
Benjamin Morel's avatar
Benjamin Morel committed
47 48 49 50

    /**
     * Quotes a string for use in a query.
     *
51
     * @param mixed  $input
Benjamin Morel's avatar
Benjamin Morel committed
52 53
     * @param integer $type
     *
54
     * @return mixed
Benjamin Morel's avatar
Benjamin Morel committed
55
     */
56
    function quote($input, $type=\PDO::PARAM_STR);
Benjamin Morel's avatar
Benjamin Morel committed
57 58 59 60 61 62 63 64

    /**
     * Executes an SQL statement and return the number of affected rows.
     *
     * @param string $statement
     *
     * @return integer
     */
65
    function exec($statement);
Benjamin Morel's avatar
Benjamin Morel committed
66 67 68 69 70 71 72 73

    /**
     * Returns the ID of the last inserted row or sequence value.
     *
     * @param string|null $name
     *
     * @return string
     */
74
    function lastInsertId($name = null);
Benjamin Morel's avatar
Benjamin Morel committed
75 76 77 78 79 80

    /**
     * Initiates a transaction.
     *
     * @return boolean TRUE on success or FALSE on failure.
     */
81
    function beginTransaction();
Benjamin Morel's avatar
Benjamin Morel committed
82 83 84 85 86 87

    /**
     * Commits a transaction.
     *
     * @return boolean TRUE on success or FALSE on failure.
     */
88
    function commit();
Benjamin Morel's avatar
Benjamin Morel committed
89 90 91 92 93 94

    /**
     * Rolls back the current transaction, as initiated by beginTransaction().
     *
     * @return boolean TRUE on success or FALSE on failure.
     */
95
    function rollBack();
Benjamin Morel's avatar
Benjamin Morel committed
96 97 98 99 100 101

    /**
     * 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.
     */
102
    function errorCode();
Benjamin Morel's avatar
Benjamin Morel committed
103 104 105 106 107 108

    /**
     * Returns extended error information associated with the last operation on the database handle.
     *
     * @return array
     */
109
    function errorInfo();
Benjamin Eberlei's avatar
Benjamin Eberlei committed
110
}