7 * Describes the API for a RedBeanPHP Database Adapter.
8 * This interface defines the API contract for
9 * a RedBeanPHP Database Adapter.
11 * @file RedBeanPHP/Adapter.php
12 * @author Gabor de Mooij and the RedBeanPHP Community
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.
23 * Should returns a string containing the most recent SQL query
24 * that has been processed by the adapter.
28 public function getSQL();
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.
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
42 public function exec( $sql, $bindings = array(), $noevent = FALSE );
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
50 * @param string $sql string containing SQL code for database
51 * @param array $bindings array of values to bind to parameters in query string
55 public function get( $sql, $bindings = array() );
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
63 * @param string $sql string containing SQL code for database
64 * @param array $bindings array of values to bind to parameters in query string
68 public function getRow( $sql, $bindings = array() );
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
76 * @param string $sql string containing SQL code for database
77 * @param array $bindings array of values to bind to parameters in query string
81 public function getCol( $sql, $bindings = array() );
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
89 * @param string $sql string containing SQL code for database
90 * @param array $bindings array of values to bind to parameters in query string
94 public function getCell( $sql, $bindings = array() );
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
104 * @param string $sql string containing SQL code for database
105 * @param array $bindings array of values to bind to parameters in query string
109 public function getAssoc( $sql, $bindings = array() );
112 * Executes the SQL query specified in $sql and indexes
113 * the row by the first column.
115 * @param string $sql Sstring containing SQL code for databaseQL
116 * @param array $bindings values to bind
120 public function getAssocRow( $sql, $bindings = array() );
123 * Returns the latest insert ID.
127 public function getInsertID();
130 * Returns the number of rows that have been
131 * affected by the last update statement.
135 public function getAffectedRows();
138 * Returns a database agnostic Cursor object.
140 * @param string $sql string containing SQL code for database
141 * @param array $bindings array of values to bind to parameters in query string
145 public function getCursor( $sql, $bindings = array() );
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.
155 public function getDatabase();
158 * This method is part of the RedBean Transaction Management
160 * Starts a transaction.
164 public function startTransaction();
167 * This method is part of the RedBean Transaction Management
169 * Commits the transaction.
173 public function commit();
176 * This method is part of the RedBean Transaction Management
178 * Rolls back the transaction.
182 public function rollback();
185 * Closes database connection.
189 public function close();