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