/
DBConnectionInterface.php
74 lines (66 loc) · 2.2 KB
/
DBConnectionInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
namespace rezord\pdo;
interface DBConnectionInterface
{
/**
* Creates new instance representing a connection to a database
* @param string $dsn The Data Source Name, or DSN, contains the information required to connect to the database.
*
* @param string $username The user name for the DSN string.
* @param string $password The password for the DSN string.
* @see http://www.php.net/manual/en/function.PDO-construct.php
* @throws PDOException if the attempt to connect to the requested database fails.
*
* @return $this DB
*/
public static function connect($dsn, $username = '', $password = '');
/**
* Completes the current session connection, and creates a new.
*
* @return void
*/
public function reconnect();
/**
* Returns the PDO instance.
*
* @return PDO the PDO instance, null if the connection is not established yet
*/
public function getPdoInstance();
/**
* Returns the ID of the last inserted row or sequence value.
*
* @param string $sequenceName name of the sequence object (required by some DBMS)
*
* @return string the row ID of the last row inserted, or the last value retrieved from the sequence object
* @see http://www.php.net/manual/en/function.PDO-lastInsertId.php
*/
public function getLastInsertID($sequenceName = '');
/**
* Closes the currently active DB connection.
* It does nothing if the connection is already closed.
*
* @return void
*/
public function close();
/**
* Sets an attribute on the database handle.
* Some of the available generic attributes are listed below;
* some drivers may make use of additional driver specific attributes.
*
* @param int $attribute
* @param mixed $value
*
* @return bool
* @see http://php.net/manual/en/pdo.setattribute.php
*/
public function setAttribute($attribute, $value);
/**
* Returns the value of a database connection attribute.
*
* @param int $attribute
*
* @return mixed
* @see http://php.net/manual/en/pdo.setattribute.php
*/
public function getAttribute($attribute);
}