1: <?php
2:
3: namespace RedBeanPHP;
4:
5: /**
6: * Interface for database drivers.
7: * The Driver API conforms to the ADODB pseudo standard
8: * for database drivers.
9: *
10: * @file RedBeanPHP/Driver.php
11: * @author Gabor de Mooij and the RedBeanPHP Community
12: * @license BSD/GPLv2
13: *
14: * @copyright
15: * copyright (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community
16: * This source file is subject to the BSD/GPLv2 License that is bundled
17: * with this source code in the file license.txt.
18: */
19: interface Driver
20: {
21: /**
22: * Runs a query and fetches results as a multi dimensional array.
23: *
24: * @param string $sql SQL query to execute
25: * @param array $bindings list of values to bind to SQL snippet
26: *
27: * @return array
28: */
29: public function GetAll( $sql, $bindings = array() );
30:
31: /**
32: * Runs a query and fetches results as a column.
33: *
34: * @param string $sql SQL query to execute
35: * @param array $bindings list of values to bind to SQL snippet
36: *
37: * @return array
38: */
39: public function GetCol( $sql, $bindings = array() );
40:
41: /**
42: * Runs a query and returns results as a single cell.
43: *
44: * @param string $sql SQL query to execute
45: * @param array $bindings list of values to bind to SQL snippet
46: *
47: * @return mixed
48: */
49: public function GetOne( $sql, $bindings = array() );
50:
51: /**
52: * Runs a query and returns results as an associative array
53: * indexed by the first column.
54: *
55: * @param string $sql SQL query to execute
56: * @param array $bindings list of values to bind to SQL snippet
57: *
58: * @return mixed
59: */
60: public function GetAssocRow( $sql, $bindings = array() );
61:
62: /**
63: * Runs a query and returns a flat array containing the values of
64: * one row.
65: *
66: * @param string $sql SQL query to execute
67: * @param array $bindings list of values to bind to SQL snippet
68: *
69: * @return array
70: */
71: public function GetRow( $sql, $bindings = array() );
72:
73: /**
74: * Executes SQL code and allows key-value binding.
75: * This function allows you to provide an array with values to bind
76: * to query parameters. For instance you can bind values to question
77: * marks in the query. Each value in the array corresponds to the
78: * question mark in the query that matches the position of the value in the
79: * array. You can also bind values using explicit keys, for instance
80: * array(":key"=>123) will bind the integer 123 to the key :key in the
81: * SQL. This method has no return value.
82: *
83: * @param string $sql SQL query to execute
84: * @param array $bindings list of values to bind to SQL snippet
85: *
86: * @return array Affected Rows
87: */
88: public function Execute( $sql, $bindings = array() );
89:
90: /**
91: * Returns the latest insert ID if driver does support this
92: * feature.
93: *
94: * @return integer
95: */
96: public function GetInsertID();
97:
98: /**
99: * Returns the number of rows affected by the most recent query
100: * if the currently selected driver driver supports this feature.
101: *
102: * @return integer
103: */
104: public function Affected_Rows();
105:
106: /**
107: * Returns a cursor-like object from the database.
108: *
109: * @param string $sql SQL query to execute
110: * @param array $bindings list of values to bind to SQL snippet
111: *
112: * @return mixed
113: */
114: public function GetCursor( $sql, $bindings = array() );
115:
116: /**
117: * Toggles debug mode. In debug mode the driver will print all
118: * SQL to the screen together with some information about the
119: * results. All SQL code that passes through the driver will be
120: * passes on to the screen for inspection.
121: * This method has no return value.
122: *
123: * @param boolean $tf TRUE = debug mode ON
124: * @param Logger $customLogger
125: *
126: * @return void
127: */
128: public function setDebugMode( $tf, $customLogger );
129:
130: /**
131: * Starts a transaction.
132: *
133: * @return void
134: */
135: public function CommitTrans();
136:
137: /**
138: * Commits a transaction.
139: *
140: * @return void
141: */
142: public function StartTrans();
143:
144: /**
145: * Rolls back a transaction.
146: *
147: * @return void
148: */
149: public function FailTrans();
150:
151: /**
152: * Resets the internal Query Counter.
153: *
154: * @return self
155: */
156: public function resetCounter();
157:
158: /**
159: * Returns the number of SQL queries processed.
160: *
161: * @return integer
162: */
163: public function getQueryCount();
164: }
165: