$chillList
$chillList : array
RedBean Object Oriented DataBase.
The RedBean OODB Class is the main class of RedBeanPHP. It takes OODBBean objects and stores them to and loads them from the database as well as providing other CRUD functions. This class acts as a object database.
$writer : \RedBeanPHP\QueryWriter
$beanhelper : \RedBeanPHP\BeanHelper|NULL
$assocManager : \RedBeanPHP\AssociationManager|NULL
$repository : \RedBeanPHP\Repository
$frozenRepository : \RedBeanPHP\Repository\Frozen|NULL
$fluidRepository : \RedBeanPHP\Repository\Fluid|NULL
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\QueryWriter $writer, array|boolean $frozen = FALSE)
Constructor, requires a query writer.
Most of the time, you do not need to use this constructor, since the facade takes care of constructing and wiring the RedBeanPHP core objects. However if you would like to assemble an OODB instance yourself, this is how it works:
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\QueryWriter | $writer | writer |
array|boolean | $frozen | mode of operation: TRUE (frozen), FALSE (default, fluid) or ARRAY (chilled) |
freeze(boolean|array $toggle) : void
Toggles fluid or frozen mode. In fluid mode the database structure is adjusted to accommodate your objects. In frozen mode this is not the case.
You can also pass an array containing a selection of frozen types. Let's call this chill mode, it's just like fluid mode except that certain types (i.e. tables) aren't touched.
boolean|array | $toggle | TRUE if you want to use OODB instance in frozen mode |
isChilled(string $type) : boolean
Determines whether a type is in the chill list.
If a type is 'chilled' it's frozen, so its schema cannot be changed anymore. However other bean types may still be modified. This method is a convenience method for other objects to check if the schema of a certain type is locked for modification.
string | $type | the type you wish to check |
dispense(string $type, string $number = 1, boolean $alwaysReturnArray = FALSE) : \RedBeanPHP\OODBBean|array<mixed,\RedBeanPHP\OODBBean>
Dispenses a new bean (a OODBBean Bean Object) of the specified type. Always use this function to get an empty bean object. Never instantiate a OODBBean yourself because it needs to be configured before you can use it with RedBean. This function applies the appropriate initialization / configuration for you.
string | $type | type of bean you want to dispense |
string | $number | number of beans you would like to get |
boolean | $alwaysReturnArray | if TRUE always returns the result as an array |
setBeanHelper(\RedBeanPHP\BeanHelper $beanhelper) : void
Sets bean helper to be given to beans.
Bean helpers assist beans in getting a reference to a toolbox.
\RedBeanPHP\BeanHelper | $beanhelper | helper |
getBeanHelper() : \RedBeanPHP\BeanHelper|NULL
Returns the current bean helper.
Bean helpers assist beans in getting a reference to a toolbox.
check(\RedBeanPHP\OODBBean $bean) : void
Checks whether a OODBBean bean is valid.
If the type is not valid or the ID is not valid it will throw an exception: Security.
\RedBeanPHP\OODBBean | $bean | the bean that needs to be checked |
find(string $type, array $conditions = array(), string|NULL $sql = NULL, array $bindings = array()) : array
Searches the database for a bean that matches conditions $conditions and sql $sql and returns an array containing all the beans that have been found.
Conditions need to take form:
array(
'PROPERTY' => array( POSSIBLE VALUES... 'John', 'Steve' )
'PROPERTY' => array( POSSIBLE VALUES... )
);
All conditions are glued together using the AND-operator, while all value lists are glued using IN-operators thus acting as OR-conditions.
Note that you can use property names; the columns will be extracted using the appropriate bean formatter.
string | $type | type of beans you are looking for |
array | $conditions | list of conditions |
string|NULL | $sql | SQL to be used in query |
array | $bindings | a list of values to bind to query parameters |
findCollection(string $type, string|NULL $sql = NULL, array $bindings = array()) : \RedBeanPHP\BeanCollection
Same as find() but returns a BeanCollection.
string | $type | type of beans you are looking for |
string|NULL | $sql | SQL to be used in query |
array | $bindings | a list of values to bind to query parameters |
store(\RedBeanPHP\OODBBean|\RedBeanPHP\SimpleModel $bean) : integer|string
Stores a bean in the database. This method takes a OODBBean Bean Object $bean and stores it in the database. If the database schema is not compatible with this bean and RedBean runs in fluid mode the schema will be altered to store the bean correctly.
If the database schema is not compatible with this bean and RedBean runs in frozen mode it will throw an exception. This function returns the primary key ID of the inserted bean.
The return value is an integer if possible. If it is not possible to represent the value as an integer a string will be returned. We use explicit casts instead of functions to preserve performance (0.13 vs 0.28 for 10000 iterations on Core i3).
\RedBeanPHP\OODBBean|\RedBeanPHP\SimpleModel | $bean | bean to store |
None found |
load(string $type, integer $id) : \RedBeanPHP\OODBBean
Loads a bean from the object database.
It searches for a OODBBean Bean Object in the database. It does not matter how this bean has been stored. RedBean uses the primary key ID $id and the string $type to find the bean. The $type specifies what kind of bean you are looking for; this is the same type as used with the dispense() function. If RedBean finds the bean it will return the OODB Bean object; if it cannot find the bean RedBean will return a new bean of type $type and with primary key ID 0. In the latter case it acts basically the same as dispense().
Important note: If the bean cannot be found in the database a new bean of the specified type will be generated and returned.
string | $type | type of bean you want to load |
integer | $id | ID of the bean you want to load |
None found |
trash(\RedBeanPHP\OODBBean|\RedBeanPHP\SimpleModel $bean) : integer
Removes a bean from the database.
This function will remove the specified OODBBean Bean Object from the database.
\RedBeanPHP\OODBBean|\RedBeanPHP\SimpleModel | $bean | bean you want to remove from database |
None found |
batch(string $type, array $ids) : array
Returns an array of beans. Pass a type and a series of ids and this method will bring you the corresponding beans.
important note: Because this method loads beans using the load() function (but faster) it will return empty beans with ID 0 for every bean that could not be located. The resulting beans will have the passed IDs as their keys.
string | $type | type of beans |
array | $ids | ids to load |
None found |
convertToBeans(string $type, array $rows, string $mask = NULL) : array
This is a convenience method; it converts database rows (arrays) into beans. Given a type and a set of rows this method will return an array of beans of the specified type loaded with the data fields provided by the result set from the database.
string | $type | type of beans you would like to have |
array | $rows | rows from the database result |
string | $mask | mask to apply for meta data |
None found |
count(string $type, string $addSQL = '', array $bindings = array()) : integer
Counts the number of beans of type $type.
This method accepts a second argument to modify the count-query. A third argument can be used to provide bindings for the SQL snippet.
string | $type | type of bean we are looking for |
string | $addSQL | additional SQL snippet |
array | $bindings | parameters to bind to SQL |
None found |
wipe(string $type) : boolean
Trash all beans of a given type. Wipes an entire type of bean.
string | $type | type of bean you wish to delete all instances of |
None found |
getAssociationManager() : \RedBeanPHP\AssociationManager
Returns an Association Manager for use with OODB.
A simple getter function to obtain a reference to the association manager used for storage and more.
None found |
setAssociationManager(\RedBeanPHP\AssociationManager $assocManager) : void
Sets the association manager instance to be used by this OODB.
A simple setter function to set the association manager to be used for storage and more.
\RedBeanPHP\AssociationManager | $assocManager | sets the association manager to be used |
None found |
getCurrentRepository() : \RedBeanPHP\Repository
Returns the currently used repository instance.
For testing purposes only.
None found |
bindFunc(string $mode, string $field, string|NULL $function, boolean $isTemplate = FALSE) : void
Binds an SQL function to a column.
This method can be used to setup a decode/encode scheme or perform UUID insertion. This method is especially useful for handling MySQL spatial columns, because they need to be processed first using the asText/GeomFromText functions.
string | $mode | mode to set function for, i.e. read or write |
string | $field | field (table.column) to bind SQL function to |
string|NULL | $function | SQL function to bind to field |
boolean | $isTemplate | TRUE if $function is an SQL string, FALSE for just a function name |
None found |
unboxIfNeeded(\RedBeanPHP\OODBBean|\RedBeanPHP\SimpleModel $bean) : \RedBeanPHP\OODBBean
Unboxes a bean from a FUSE model if needed and checks whether the bean is an instance of OODBBean.
\RedBeanPHP\OODBBean|\RedBeanPHP\SimpleModel | $bean | bean you wish to unbox |
None found |