-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIConnection.php
More file actions
128 lines (112 loc) · 3.81 KB
/
IConnection.php
File metadata and controls
128 lines (112 loc) · 3.81 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/*
* Opulence
*
* @link https://www.opulencephp.com
* @copyright Copyright (C) 2021 David Young
* @license https://github.com/opulencephp/Opulence/blob/1.2/LICENSE.md
*/
namespace Opulence\Databases;
use Opulence\Databases\Providers\Provider;
use PDO;
use PDOException;
/**
* Defines the database connection interface, which must be implemented by any classes that wish to be used
* as a database connection in this application
*/
interface IConnection
{
/**
* Begins a transaction
* Nested transactions are permitted
*
* @throws PDOException Thrown if there was an error connecting to the database
*/
public function beginTransaction();
/**
* Commits a transaction
* If we are in a nested transaction and this isn't the final commit of the nested transactions, nothing happens
*
* @throws PDOException Thrown if there was an error connecting to the database
*/
public function commit();
/**
* Gets the SQLSTATE of the last query, if there was one
*
* @return string|null The error code, if one was set, otherwise false
* @throws PDOException Thrown if there was an error connecting to the database
*/
public function errorCode();
/**
* Gets information about the last query error
*
* @return array The array of information about the last operation
* @throws PDOException Thrown if there was an error connecting to the database
*/
public function errorInfo();
/**
* Executes an SQL statement in a single call
*
* @param string $statement The SQL statement to execute
* @return int The number of rows affected by the statement
* @throws PDOException Thrown if there was an error connecting to the database
*/
public function exec($statement);
/**
* Gets the database provider used by this connection
*
* @return Provider The database provider used by this connection
*/
public function getDatabaseProvider();
/**
* Gets the server used in the connection
*
* @return Server The server used in the connection
*/
public function getServer();
/**
* Gets whether or not we're in a transaction
*
* @return bool True if we're in a transaction, otherwise false
* @throws PDOException Thrown if there was an error connecting to the database
*/
public function inTransaction();
/**
* Gets the last insert Id
*
* @param string $sequenceName The name of the sequence whose Id we want
* @return string The Id of the last row in the input sequence
*/
public function lastInsertId($sequenceName = null);
/**
* Prepares an SQL statement for execution
*
* @param string $statement The SQL statement to execute
* @return IStatement The statement
* @throws PDOException Thrown if there was an error connecting to the database
*/
public function prepare($statement);
/**
* Executes an SQL statement and gets the statement object
*
* @param string $statement The SQL statement to execute
* @return IStatement The statement
* @throws PDOException Thrown if there was an error connecting to the database
*/
public function query($statement);
/**
* Quotes a string for use in a query
*
* @param string $string The string to quote
* @param int $parameterType The PDO constant that indicates the type of the parameter
* @return string The quoted string
* @throws PDOException Thrown if there was an error connecting to the database
*/
public function quote($string, $parameterType = PDO::PARAM_STR);
/**
* Rolls back the transaction
*
* @throws PDOException Thrown if there was an error connecting to the database
*/
public function rollBack();
}