1: <?php
2:
3: namespace RedBeanPHP;
4:
5: /**
6: * Adapter Interface.
7: * Describes the API for a RedBeanPHP Database Adapter.
8: * This interface defines the API contract for
9: * a RedBeanPHP Database Adapter.
10: *
11: * @file RedBeanPHP/Adapter.php
12: * @author Gabor de Mooij and the RedBeanPHP Community
13: * @license BSD/GPLv2
14: *
15: * @copyright
16: * (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
17: * This source file is subject to the BSD/GPLv2 License that is bundled
18: * with this source code in the file license.txt.
19: */
20: interface Adapter
21: {
22: /**
23: * Returns the latest SQL statement.
24: *
25: * @return string
26: */
27: public function getSQL();
28:
29: /**
30: * Executes an SQL Statement using an array of values to bind
31: * If $noevent is TRUE then this function will not signal its
32: * observers to notify about the SQL execution; this to prevent
33: * infinite recursion when using observers.
34: *
35: * @param string $sql string containing SQL code for database
36: * @param array $bindings array of values to bind to parameters in query string
37: * @param boolean $noevent no event firing
38: *
39: * @return void
40: */
41: public function exec( $sql, $bindings = array(), $noevent = FALSE );
42:
43: /**
44: * Executes an SQL Query and returns a resultset.
45: * This method returns a multi dimensional resultset similar to getAll
46: * The values array can be used to bind values to the place holders in the
47: * SQL query.
48: *
49: * @param string $sql string containing SQL code for database
50: * @param array $bindings array of values to bind to parameters in query string
51: *
52: * @return array
53: */
54: public function get( $sql, $bindings = array() );
55:
56: /**
57: * Executes an SQL Query and returns a resultset.
58: * This method returns a single row (one array) resultset.
59: * The values array can be used to bind values to the place holders in the
60: * SQL query.
61: *
62: * @param string $sql string containing SQL code for database
63: * @param array $bindings array of values to bind to parameters in query string
64: *
65: * @return array
66: */
67: public function getRow( $sql, $bindings = array() );
68:
69: /**
70: * Executes an SQL Query and returns a resultset.
71: * This method returns a single column (one array) resultset.
72: * The values array can be used to bind values to the place holders in the
73: * SQL query.
74: *
75: * @param string $sql string containing SQL code for database
76: * @param array $bindings array of values to bind to parameters in query string
77: *
78: * @return array
79: */
80: public function getCol( $sql, $bindings = array() );
81:
82: /**
83: * Executes an SQL Query and returns a resultset.
84: * This method returns a single cell, a scalar value as the resultset.
85: * The values array can be used to bind values to the place holders in the
86: * SQL query.
87: *
88: * @param string $sql string containing SQL code for database
89: * @param array $bindings array of values to bind to parameters in query string
90: *
91: * @return string
92: */
93: public function getCell( $sql, $bindings = array() );
94:
95: /**
96: * Executes the SQL query specified in $sql and takes
97: * the first two columns of the resultset. This function transforms the
98: * resultset into an associative array. Values from the the first column will
99: * serve as keys while the values of the second column will be used as values.
100: * The values array can be used to bind values to the place holders in the
101: * SQL query.
102: *
103: * @param string $sql string containing SQL code for database
104: * @param array $bindings array of values to bind to parameters in query string
105: *
106: * @return array
107: */
108: public function getAssoc( $sql, $bindings = array() );
109:
110: /**
111: * Executes the SQL query specified in $sql and indexes
112: * the row by the first column.
113: *
114: * @param string $sql Sstring containing SQL code for databaseQL
115: * @param array $bindings values to bind
116: *
117: * @return array
118: */
119: public function getAssocRow( $sql, $bindings = array() );
120:
121: /**
122: * Returns the latest insert ID.
123: *
124: * @return integer
125: */
126: public function getInsertID();
127:
128: /**
129: * Returns the number of rows that have been
130: * affected by the last update statement.
131: *
132: * @return integer
133: */
134: public function getAffectedRows();
135:
136: /**
137: * Returns a database agnostic Cursor object.
138: *
139: * @param string $sql string containing SQL code for database
140: * @param array $bindings array of values to bind to parameters in query string
141: *
142: * @return Cursor
143: */
144: public function getCursor( $sql, $bindings = array() );
145:
146: /**
147: * Returns the original database resource. This is useful if you want to
148: * perform operations on the driver directly instead of working with the
149: * adapter. RedBean will only access the adapter and never to talk
150: * directly to the driver though.
151: *
152: * @return mixed
153: */
154: public function getDatabase();
155:
156: /**
157: * This method is part of the RedBean Transaction Management
158: * mechanisms.
159: * Starts a transaction.
160: *
161: * @return void
162: */
163: public function startTransaction();
164:
165: /**
166: * This method is part of the RedBean Transaction Management
167: * mechanisms.
168: * Commits the transaction.
169: *
170: * @return void
171: */
172: public function commit();
173:
174: /**
175: * This method is part of the RedBean Transaction Management
176: * mechanisms.
177: * Rolls back the transaction.
178: *
179: * @return void
180: */
181: public function rollback();
182:
183: /**
184: * Closes database connection.
185: *
186: * @return void
187: */
188: public function close();
189: }
190: