$observers
$observers : array
DBAdapter (Database Adapter)
An adapter class to connect various database systems to RedBean Database Adapter Class. The task of the database adapter class is to communicate with the database driver. You can use all sorts of database drivers with RedBeanPHP. The default database drivers that ships with the RedBeanPHP library is the RPDO driver ( which uses the PHP Data Objects Architecture aka PDO ).
$db : \RedBeanPHP\Driver
addEventListener(string $eventname, \RedBeanPHP\Observer $observer) : void
Implementation of the Observer Pattern.
Adds an event listener to the observable object. First argument should be the name of the event you wish to listen for. Second argument should be the object that wants to be notified in case the event occurs.
string | $eventname | event identifier |
\RedBeanPHP\Observer | $observer | observer instance |
signal(string $eventname, mixed $info) : void
Notifies listeners.
Sends the signal $eventname, the event identifier and a message object to all observers that have been registered to receive notification for this event. Part of the observer pattern implementation in RedBeanPHP.
string | $eventname | event you want signal |
mixed | $info | message object to send along |
__construct(\RedBeanPHP\Driver $database)
Constructor.
Creates an instance of the RedBean Adapter Class. This class provides an interface for RedBean to work with ADO compatible DB instances.
Usage:
$database = new RPDO( $dsn, $user, $pass );
$adapter = new DBAdapter( $database );
$writer = new PostgresWriter( $adapter );
$oodb = new OODB( $writer, FALSE );
$bean = $oodb->dispense( 'bean' );
$bean->name = 'coffeeBean';
$id = $oodb->store( $bean );
$bean = $oodb->load( 'bean', $id );
The example above creates the 3 RedBeanPHP core objects: the Adapter, the Query Writer and the OODB instance and wires them together. The example also demonstrates some of the methods that can be used with OODB, as you see, they closely resemble their facade counterparts.
The wiring process: create an RPDO instance using your database connection parameters. Create a database adapter from the RPDO object and pass that to the constructor of the writer. Next, create an OODB instance from the writer. Now you have an OODB object.
\RedBeanPHP\Driver | $database | ADO Compatible DB Instance |
exec(string $sql, array $bindings = array(), boolean $noevent = FALSE) : integer
Executes an SQL Statement using an array of values to bind If $noevent is TRUE then this function will not signal its observers to notify about the SQL execution; this to prevent infinite recursion when using observers.
string | $sql | string containing SQL code for database |
array | $bindings | array of values to bind to parameters in query string |
boolean | $noevent | no event firing |
get(string $sql, array $bindings = array()) : array
Executes an SQL Query and returns a resultset.
This method returns a multi dimensional resultset similar to getAll The values array can be used to bind values to the place holders in the SQL query.
string | $sql | string containing SQL code for database |
array | $bindings | array of values to bind to parameters in query string |
getRow(string $sql, array $bindings = array()) : array|NULL
Executes an SQL Query and returns a resultset.
This method returns a single row (one array) resultset. The values array can be used to bind values to the place holders in the SQL query.
string | $sql | string containing SQL code for database |
array | $bindings | array of values to bind to parameters in query string |
getCol(string $sql, array $bindings = array()) : array
Executes an SQL Query and returns a resultset.
This method returns a single column (one array) resultset. The values array can be used to bind values to the place holders in the SQL query.
string | $sql | string containing SQL code for database |
array | $bindings | array of values to bind to parameters in query string |
getCell(string $sql, array $bindings = array(), $noSignal = NULL) : string|NULL
Executes an SQL Query and returns a resultset.
This method returns a single cell, a scalar value as the resultset. The values array can be used to bind values to the place holders in the SQL query.
string | $sql | string containing SQL code for database |
array | $bindings | array of values to bind to parameters in query string |
$noSignal |
getCursor(string $sql, array $bindings = array()) : \RedBeanPHP\Cursor
Returns a database agnostic Cursor object.
string | $sql | string containing SQL code for database |
array | $bindings | array of values to bind to parameters in query string |
getDatabase() : \RedBeanPHP\Driver
Returns the original database resource. This is useful if you want to perform operations on the driver directly instead of working with the adapter. RedBean will only access the adapter and never to talk directly to the driver though.
setOption(string $optionKey, string $optionValue) : boolean
Sets a driver specific option.
Using this method you can access driver-specific functions. If the selected option exists the value will be passed and this method will return boolean TRUE, otherwise it will return boolean FALSE.
string | $optionKey | option key |
string | $optionValue | option value |