1 <?php
2 /**
3 * Neevo - Tiny database layer for PHP. (http://neevo.smasty.net)
4 *
5 * This source file is subject to the MIT license that is bundled
6 * with this package in the file license.txt.
7 *
8 * Copyright (c) 2011 Martin Srank (http://smasty.net)
9 *
10 */
11
12
13 /**
14 * Interface implemented by all Neevo drivers.
15 *
16 * All Neevo drivers **must** implement this interface, not only reproduce all it's
17 * methods, or they won't be recognised as valid drivers.
18 *
19 * If something is not implemented, the method **must** throw NeevoImplementationException.
20 * The exception will be catched and Neevo will decide, what to do next.
21 *
22 * If something is not supported by the driver (e.g. number of result rows on unbuffered queries)
23 * the driver should throw NeevoDriverException.
24 *
25 * When the driver needs to rewrite default output of SQL commands, it **must**
26 * extend **NeevoParser** class. For proper use, see
27 * "source of **NeevoParser** class":./source-neevo.NeevoParser.php.html.
28 *
29 * @author Martin Srank
30 * @package Neevo\Drivers
31 */
32 interface INeevoDriver {
33
34
35 /**
36 * Check for required PHP extension.
37 * @return void
38 * @throws NeevoDriverException
39 */
40 public function __construct();
41
42
43 /**
44 * Create connection to database.
45 * @param array $config Configuration options
46 * @return void
47 */
48 public function connect(array $config);
49
50
51 /**
52 * Close the connection.
53 * @return void
54 */
55 public function closeConnection();
56
57
58 /**
59 * Free memory used by given result.
60 * @param resource $resultSet
61 * @return bool
62 */
63 public function freeResultSet($resultSet);
64
65
66 /**
67 * Execute given SQL statement.
68 * @param string $queryString
69 * @return resource|bool
70 */
71 public function runQuery($queryString);
72
73
74 /**
75 * Begin a transaction if supported.
76 * @param string $savepoint
77 * @return void
78 */
79 public function beginTransaction($savepoint = null);
80
81
82 /**
83 * Commit statements in a transaction.
84 * @param string $avepoint
85 * @return void
86 */
87 public function commit($savepoint = null);
88
89
90 /**
91 * Rollback changes in a transaction.
92 * @param string $savepoint
93 * @return void
94 */
95 public function rollback($savepoint = null);
96
97
98 /**
99 * Fetch row from given result set as an associative array.
100 * @param resource $resultSet
101 * @return array
102 */
103 public function fetch($resultSet);
104
105
106 /**
107 * Move internal result pointer.
108 * @param resource $resultSet
109 * @param int $offset
110 * @return bool
111 */
112 public function seek($resultSet, $offset);
113
114
115 /**
116 * Get the ID generated in the INSERT statement.
117 * @return int
118 */
119 public function getInsertId();
120
121
122 /**
123 * Randomize result order.
124 * @param NeevoBaseStmt $statement
125 * @return void
126 */
127 public function randomizeOrder(NeevoBaseStmt $statement);
128
129
130 /**
131 * Get the number of rows in the given result set.
132 * @param resource $resultSet
133 * @return int|FALSE
134 */
135 public function getNumRows($resultSet);
136
137
138 /**
139 * Get the number of affected rows in previous operation.
140 * @return int
141 */
142 public function getAffectedRows();
143
144
145 /**
146 * Escape given value.
147 * @param mixed $value
148 * @param string $type
149 * @return mixed
150 */
151 public function escape($value, $type);
152
153
154 /**
155 * Decode given value.
156 * @param mixed $value
157 * @param string $type
158 * @return mixed
159 */
160 public function unescape($value, $type);
161
162
163 /**
164 * Get the PRIMARY KEY column for given table.
165 * @param string $table
166 * @return string|NULL
167 */
168 public function getPrimaryKey($table);
169
170
171 /**
172 * Get types of columns in given result set.
173 * @param resource $resultSet
174 * @param string $table
175 * @return array
176 */
177 public function getColumnTypes($resultSet, $table);
178
179
180 }
181