Overview

Namespaces

  • None
  • RedBeanPHP
    • Adapter
    • BeanHelper
    • Cursor
    • Driver
    • Logger
      • RDefault
    • QueryWriter
    • RedException
    • Repository
    • Util

Classes

  • AssociationManager
  • BeanCollection
  • DuplicationManager
  • Facade
  • Finder
  • Jsonable
  • LabelMaker
  • Observable
  • OODB
  • OODBBean
  • R
  • Repository
  • SimpleModel
  • SimpleModelHelper
  • TagManager
  • ToolBox

Interfaces

  • Adapter
  • BeanHelper
  • Cursor
  • Driver
  • Logger
  • Observer
  • Plugin
  • QueryWriter

Exceptions

  • RedException
  • Overview
  • Namespace
  • Class

Class OODBBean

OODBBean (Object Oriented DataBase Bean).

to exchange information with the database. A bean represents a single table row and offers generic services for interaction with databases systems as well as some meta-data.

RedBeanPHP\OODBBean implements IteratorAggregate, ArrayAccess, Countable, RedBeanPHP\Jsonable
Namespace: RedBeanPHP
Copyright:

copyright (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community. This source file is subject to the BSD/GPLv2 License that is bundled with this source code in the file license.txt.


License: BSD/GPLv2
Author: Gabor de Mooij and the RedBeanPHP community
Desc: OODBBean represents a bean. RedBeanPHP uses beans
File: RedBeanPHP/OODBBean.php
Located at OODBBean.php
Methods summary
public static array
# setErrorHandlingFUSE( integer $mode, callable|null $func = NULL )

Sets the error mode for FUSE. What to do if a FUSE model method does not exist? You can set the following options:

Sets the error mode for FUSE. What to do if a FUSE model method does not exist? You can set the following options:

  • OODBBean::C_ERR_IGNORE (default), ignores the call, returns NULL
  • OODBBean::C_ERR_LOG, logs the incident using error_log
  • OODBBean::C_ERR_NOTICE, triggers a E_USER_NOTICE
  • OODBBean::C_ERR_WARN, triggers a E_USER_WARNING
  • OODBBean::C_ERR_EXCEPTION, throws an exception
  • OODBBean::C_ERR_FUNC, allows you to specify a custom handler (function)
  • OODBBean::C_ERR_FATAL, triggers a E_USER_ERROR
Custom handler method signature: handler( array (
    'message' => string
    'bean' => OODBBean
    'method' => string
) )

This method returns the old mode and handler as an array.

Parameters

$mode
error handling mode
$func
custom handler

Returns

array
public static
# aliases( array $list )

Sets global aliases. Registers a batch of aliases in one go. This works the same as fetchAs and setAutoResolve but explicitly. For instance if you register the alias 'cover' for 'page' a property containing a reference to a page bean called 'cover' will correctly return the page bean and not a (non-existant) cover bean.

Sets global aliases. Registers a batch of aliases in one go. This works the same as fetchAs and setAutoResolve but explicitly. For instance if you register the alias 'cover' for 'page' a property containing a reference to a page bean called 'cover' will correctly return the page bean and not a (non-existant) cover bean.

R::aliases( array( 'cover' => 'page' ) );
$book = R::dispense( 'book' );
$page = R::dispense( 'page' );
$book->cover = $page;
R::store( $book );
$book = $book->fresh();
$cover = $book->cover;
echo $cover->getMeta( 'type' ); //page

The format of the aliases registration array is:

{alias} => {actual type}

In the example above we use:

cover => page

From that point on, every bean reference to a cover will return a 'page' bean. Note that with autoResolve this feature along with fetchAs() is no longer very important, although relying on explicit aliases can be a bit faster.

Parameters

$list
list of global aliases to use
public static
# setAutoResolve( boolean $automatic = TRUE )

Enables or disables auto-resolving fetch types. Auto-resolving aliased parent beans is convenient but can be slower and can create infinite recursion if you used aliases to break cyclic relations in your domain.

Enables or disables auto-resolving fetch types. Auto-resolving aliased parent beans is convenient but can be slower and can create infinite recursion if you used aliases to break cyclic relations in your domain.

Parameters

$automatic
TRUE to enable automatic resolving aliased parents
public static array
# setMetaAll( array $beans, string $property, mixed $value )

Sets a meta property for all beans. This is a quicker way to set the meta properties for a collection of beans because this method can directly access the property arrays of the beans. This method returns the beans.

Sets a meta property for all beans. This is a quicker way to set the meta properties for a collection of beans because this method can directly access the property arrays of the beans. This method returns the beans.

Parameters

$beans
beans to set the meta property of
$property
property to set
$value
value

Returns

array
public
# initializeForDispense( string $type, RedBeanPHP\BeanHelper $beanhelper )

Initializes a bean. Used by OODB for dispensing beans. It is not recommended to use this method to initialize beans. Instead use the OODB object to dispense new beans. You can use this method if you build your own bean dispensing mechanism.

Initializes a bean. Used by OODB for dispensing beans. It is not recommended to use this method to initialize beans. Instead use the OODB object to dispense new beans. You can use this method if you build your own bean dispensing mechanism.

Parameters

$type
type of the new bean
$beanhelper
bean helper to obtain a toolbox and a model
public
# setBeanHelper( RedBeanPHP\BeanHelper $helper )

Sets the Bean Helper. Normally the Bean Helper is set by OODB. Here you can change the Bean Helper. The Bean Helper is an object providing access to a toolbox for the bean necessary to retrieve nested beans (bean lists: ownBean, sharedBean) without the need to rely on static calls to the facade (or make this class dep. on OODB).

Sets the Bean Helper. Normally the Bean Helper is set by OODB. Here you can change the Bean Helper. The Bean Helper is an object providing access to a toolbox for the bean necessary to retrieve nested beans (bean lists: ownBean, sharedBean) without the need to rely on static calls to the facade (or make this class dep. on OODB).

Parameters

$helper
helper to use for this bean
public ArrayIterator
# getIterator( )

Returns an ArrayIterator so you can treat the bean like an array with the properties container as its contents. This method is meant for PHP and allows you to access beans as if they were arrays, i.e. using array notation:

Returns an ArrayIterator so you can treat the bean like an array with the properties container as its contents. This method is meant for PHP and allows you to access beans as if they were arrays, i.e. using array notation:

$bean[$key] = $value;

Note that not all PHP functions work with the array interface.

Returns

ArrayIterator

Implementation of

IteratorAggregate::getIterator()
public RedBeanPHP\OODBBean
# import( array $array, string|array $selection = FALSE, boolean $notrim = FALSE )

Imports all values from an associative array $array. Chainable. This method imports the values in the first argument as bean propery and value pairs. Use the second parameter to provide a selection. If a selection array is passed, only the entries having keys mentioned in the selection array will be imported. Set the third parameter to TRUE to preserve spaces in selection keys.

Imports all values from an associative array $array. Chainable. This method imports the values in the first argument as bean propery and value pairs. Use the second parameter to provide a selection. If a selection array is passed, only the entries having keys mentioned in the selection array will be imported. Set the third parameter to TRUE to preserve spaces in selection keys.

Parameters

$array
what you want to import
$selection
selection of values
$notrim
if TRUE selection keys will NOT be trimmed

Returns

RedBeanPHP\OODBBean
public RedBeanPHP\OODBBean
# importRow( array $row )

Fast way to import a row. Does not perform any checks.

Fast way to import a row. Does not perform any checks.

Parameters

$row
a database row

Returns

RedBeanPHP\OODBBean
public RedBeanPHP\OODBBean
# importFrom( RedBeanPHP\OODBBean $sourceBean )

Imports data from another bean. Chainable. Copies the properties from the source bean to the internal property list.

Imports data from another bean. Chainable. Copies the properties from the source bean to the internal property list.

Parameters

$sourceBean
the source bean to take properties from

Returns

RedBeanPHP\OODBBean
public RedBeanPHP\OODBBean
# inject( RedBeanPHP\OODBBean $otherBean )

Injects the properties of another bean but keeps the original ID. Just like import() but keeps the original ID. Chainable.

Injects the properties of another bean but keeps the original ID. Just like import() but keeps the original ID. Chainable.

Parameters

$otherBean
the bean whose properties you would like to copy

Returns

RedBeanPHP\OODBBean
public array
# export( boolean $meta = FALSE, boolean $parents = FALSE, boolean $onlyMe = FALSE, array $filters = array() )

Exports the bean as an array. This function exports the contents of a bean to an array and returns the resulting array.

Exports the bean as an array. This function exports the contents of a bean to an array and returns the resulting array.

Parameters

$meta
set to TRUE if you want to export meta data as well
$parents
set to TRUE if you want to export parents as well
$onlyMe
set to TRUE if you want to export only this bean
$filters
optional whitelist for export

Returns

array
public boolean
# __isset( string $property )

Implements isset() function for use as an array.

Implements isset() function for use as an array.

Parameters

$property
name of the property you want to check

Returns

boolean
public string|null
# getID( )

Returns the ID of the bean no matter what the ID field is.

Returns the ID of the bean no matter what the ID field is.

Returns

string|null
public
# __unset( string $property )

Unsets a property of a bean. Magic method, gets called implicitly when performing the unset() operation on a bean property.

Unsets a property of a bean. Magic method, gets called implicitly when performing the unset() operation on a bean property.

Parameters

$property
property to unset
public RedBeanPHP\OODBBean
# with( string $sql, array $bindings = array() )

Adds WHERE clause conditions to ownList retrieval. For instance to get the pages that belong to a book you would issue the following command: $book->ownPage However, to order these pages by number use:

Adds WHERE clause conditions to ownList retrieval. For instance to get the pages that belong to a book you would issue the following command: $book->ownPage However, to order these pages by number use:

$book->with(' ORDER BY `number` ASC ')->ownPage

the additional SQL snippet will be merged into the final query.

Parameters

$sql
SQL to be added to retrieval query.
$bindings
array with parameters to bind to SQL snippet

Returns

RedBeanPHP\OODBBean
public RedBeanPHP\OODBBean
# withCondition( string $sql, array $bindings = array() )

Just like with(). Except that this method prepends the SQL query snippet with AND which makes it slightly more comfortable to use a conditional SQL snippet. For instance to filter an own-list with pages (belonging to a book) on specific chapters you can use:

Just like with(). Except that this method prepends the SQL query snippet with AND which makes it slightly more comfortable to use a conditional SQL snippet. For instance to filter an own-list with pages (belonging to a book) on specific chapters you can use:

$book->withCondition(' chapter = 3 ')->ownPage

This will return in the own list only the pages having 'chapter == 3'.

Parameters

$sql
SQL to be added to retrieval query (prefixed by AND)
$bindings
array with parameters to bind to SQL snippet

Returns

RedBeanPHP\OODBBean
public RedBeanPHP\OODBBean
# all( )

Tells the bean to (re)load the following list without any conditions. If you have an ownList or sharedList with a condition you can use this method to reload the entire list.

Tells the bean to (re)load the following list without any conditions. If you have an ownList or sharedList with a condition you can use this method to reload the entire list.

Usage:

$bean->with( ' LIMIT 3 ' )->ownPage; //Just 3
$bean->all()->ownPage; //Reload all pages

Returns

RedBeanPHP\OODBBean
public RedBeanPHP\OODBBean
# noLoad( )

Tells the bean to only access the list but not load its contents. Use this if you only want to add something to a list and you have no interest in retrieving its contents from the database.

Tells the bean to only access the list but not load its contents. Use this if you only want to add something to a list and you have no interest in retrieving its contents from the database.

Returns

RedBeanPHP\OODBBean
public RedBeanPHP\OODBBean
# alias( string $aliasName )

Prepares an own-list to use an alias. This is best explained using an example. Imagine a project and a person. The project always involves two persons: a teacher and a student. The person beans have been aliased in this case, so to the project has a teacher_id pointing to a person, and a student_id also pointing to a person. Given a project, we obtain the teacher like this:

Prepares an own-list to use an alias. This is best explained using an example. Imagine a project and a person. The project always involves two persons: a teacher and a student. The person beans have been aliased in this case, so to the project has a teacher_id pointing to a person, and a student_id also pointing to a person. Given a project, we obtain the teacher like this:

$project->fetchAs('person')->teacher;

Now, if we want all projects of a teacher we cant say:

$teacher->ownProject

because the $teacher is a bean of type 'person' and no project has been assigned to a person. Instead we use the alias() method like this:

$teacher->alias('teacher')->ownProject

now we get the projects associated with the person bean aliased as a teacher.

Parameters

$aliasName
the alias name to use

Returns

RedBeanPHP\OODBBean
public array
# getProperties( )

Returns properties of bean as an array. This method returns the raw internal property list of the bean. Only use this method for optimization purposes. Otherwise use the export() method to export bean data to arrays.

Returns properties of bean as an array. This method returns the raw internal property list of the bean. Only use this method for optimization purposes. Otherwise use the export() method to export bean data to arrays.

Returns

array
public array
# getPropertiesAndType( )

Returns properties of bean as an array. This method returns the raw internal property list of the bean. Only use this method for optimization purposes. Otherwise use the export() method to export bean data to arrays. This method returns an array with the properties array and the type (string).

Returns properties of bean as an array. This method returns the raw internal property list of the bean. Only use this method for optimization purposes. Otherwise use the export() method to export bean data to arrays. This method returns an array with the properties array and the type (string).

Returns

array
public string
# beau( string $property )

Turns a camelcase property name into an underscored property name.

Turns a camelcase property name into an underscored property name.

Examples:

  • oneACLRoute -> one_acl_route
  • camelCase -> camel_case

Also caches the result to improve performance.

Parameters

$property
property to un-beautify

Returns

string
public RedBeanPHP\OODBBean
# clearModifiers( )

Clears all modifiers.

Clears all modifiers.

Returns

RedBeanPHP\OODBBean
public boolean
# isListInExclusiveMode( string $listName )

Determines whether a list is opened in exclusive mode or not. If a list has been opened in exclusive mode this method will return TRUE, othwerwise it will return FALSE.

Determines whether a list is opened in exclusive mode or not. If a list has been opened in exclusive mode this method will return TRUE, othwerwise it will return FALSE.

Parameters

$listName
name of the list to check

Returns

boolean
public mixed &
# __get( string $property )

Magic Getter. Gets the value for a specific property in the bean. If the property does not exist this getter will make sure no error occurs. This is because RedBean allows you to query (probe) for properties. If the property can not be found this method will return NULL instead.

Magic Getter. Gets the value for a specific property in the bean. If the property does not exist this getter will make sure no error occurs. This is because RedBean allows you to query (probe) for properties. If the property can not be found this method will return NULL instead.

Parameters

$property
name of the property you wish to obtain the value of

Returns

mixed
public
# __set( string $property, mixed $value )

Magic Setter. Sets the value for a specific property. This setter acts as a hook for OODB to mark beans as tainted. The tainted meta property can be retrieved using getMeta("tainted"). The tainted meta property indicates whether a bean has been modified and can be used in various caching mechanisms.

Magic Setter. Sets the value for a specific property. This setter acts as a hook for OODB to mark beans as tainted. The tainted meta property can be retrieved using getMeta("tainted"). The tainted meta property indicates whether a bean has been modified and can be used in various caching mechanisms.

Parameters

$property
name of the property you wish to assign a value to
$value
the value you want to assign
public
# setProperty( string $property, mixed $value, boolean $updateShadow = FALSE, boolean $taint = FALSE )

Sets a property directly, for internal use only.

Sets a property directly, for internal use only.

Parameters

$property
property
$value
value
$updateShadow
whether you want to update the shadow
$taint
whether you want to mark the bean as tainted
public mixed
# getMeta( string $path, mixed $default = NULL )

Returns the value of a meta property. A meta property contains additional information about the bean object that will not be stored in the database. Meta information is used to instruct RedBeanPHP as well as other systems how to deal with the bean. If the property cannot be found this getter will return NULL instead.

Returns the value of a meta property. A meta property contains additional information about the bean object that will not be stored in the database. Meta information is used to instruct RedBeanPHP as well as other systems how to deal with the bean. If the property cannot be found this getter will return NULL instead.

Example:

$bean->setMeta( 'flush-cache', TRUE );

RedBeanPHP also stores meta data in beans, this meta data uses keys prefixed with 'sys.' (system).

Parameters

$path
path to property in meta data
$default
default value

Returns

mixed
public mixed
# moveMeta( string $path, mixed $value = NULL )

Gets and unsets a meta property. Moves a meta property out of the bean. This is a short-cut method that can be used instead of combining a get/unset.

Gets and unsets a meta property. Moves a meta property out of the bean. This is a short-cut method that can be used instead of combining a get/unset.

Parameters

$path
path to property in meta data
$value
$default default value

Returns

mixed
public RedBeanPHP\OODBBean
# setMeta( string $path, mixed $value )

Stores a value in the specified Meta information property. The first argument should be the key to store the value under, the second argument should be the value. It is common to use a path-like notation for meta data in RedBeanPHP like: 'my.meta.data', however the dots are purely for readability, the meta data methods do not store nested structures or hierarchies.

Stores a value in the specified Meta information property. The first argument should be the key to store the value under, the second argument should be the value. It is common to use a path-like notation for meta data in RedBeanPHP like: 'my.meta.data', however the dots are purely for readability, the meta data methods do not store nested structures or hierarchies.

Parameters

$path
path / key to store value under
$value
value to store in bean (not in database) as meta data

Returns

RedBeanPHP\OODBBean
public RedBeanPHP\OODBBean
# copyMetaFrom( RedBeanPHP\OODBBean $bean )

Copies the meta information of the specified bean This is a convenience method to enable you to exchange meta information easily.

Copies the meta information of the specified bean This is a convenience method to enable you to exchange meta information easily.

Parameters

$bean
bean to copy meta data of

Returns

RedBeanPHP\OODBBean
public mixed
# __call( string $method, array $args )

Sends the call to the registered model.

Sends the call to the registered model.

Parameters

$method
name of the method
$args
argument list

Returns

mixed
public string
# __toString( )

Implementation of __toString Method Routes call to Model. If the model implements a __toString() method this method will be called and the result will be returned. In case of an echo-statement this result will be printed. If the model does not implement a __toString method, this method will return a JSON representation of the current bean.

Implementation of __toString Method Routes call to Model. If the model implements a __toString() method this method will be called and the result will be returned. In case of an echo-statement this result will be printed. If the model does not implement a __toString method, this method will return a JSON representation of the current bean.

Returns

string
public
# offsetSet( mixed $offset, mixed $value )

Implementation of Array Access Interface, you can access bean objects like an array. Call gets routed to __set.

Implementation of Array Access Interface, you can access bean objects like an array. Call gets routed to __set.

Parameters

$offset
offset string
$value
value

Implementation of

ArrayAccess::offsetSet()
public boolean
# offsetExists( mixed $offset )

Implementation of Array Access Interface, you can access bean objects like an array.

Implementation of Array Access Interface, you can access bean objects like an array.

Array functions do not reveal x-own-lists and list-alias because you dont want duplicate entries in foreach-loops. Also offers a slight performance improvement for array access.

Parameters

$offset
property

Returns

boolean

Implementation of

ArrayAccess::offsetExists()
public
# offsetUnset( mixed $offset )

Implementation of Array Access Interface, you can access bean objects like an array. Unsets a value from the array/bean.

Implementation of Array Access Interface, you can access bean objects like an array. Unsets a value from the array/bean.

Array functions do not reveal x-own-lists and list-alias because you dont want duplicate entries in foreach-loops. Also offers a slight performance improvement for array access.

Parameters

$offset
property

Implementation of

ArrayAccess::offsetUnset()
public mixed &
# offsetGet( mixed $offset )

Implementation of Array Access Interface, you can access bean objects like an array. Returns value of a property.

Implementation of Array Access Interface, you can access bean objects like an array. Returns value of a property.

Array functions do not reveal x-own-lists and list-alias because you dont want duplicate entries in foreach-loops. Also offers a slight performance improvement for array access.

Parameters

$offset
property

Returns

mixed

Implementation of

ArrayAccess::offsetGet()
public RedBeanPHP\OODBBean
# fetchAs( string $type )

Chainable method to cast a certain ID to a bean; for instance: $person = $club->fetchAs('person')->member; This will load a bean of type person using member_id as ID.

Chainable method to cast a certain ID to a bean; for instance: $person = $club->fetchAs('person')->member; This will load a bean of type person using member_id as ID.

Parameters

$type
preferred fetch type

Returns

RedBeanPHP\OODBBean
public RedBeanPHP\OODBBean
# poly( string $field )

For polymorphic bean relations. Same as fetchAs but uses a column instead of a direct value.

For polymorphic bean relations. Same as fetchAs but uses a column instead of a direct value.

Parameters

$field
field name to use for mapping

Returns

RedBeanPHP\OODBBean
public RedBeanPHP\OODBBean
# traverse( string $property, callable $function, integer $maxDepth = NULL )

Traverses a bean property with the specified function. Recursively iterates through the property invoking the function for each bean along the way passing the bean to it.

Traverses a bean property with the specified function. Recursively iterates through the property invoking the function for each bean along the way passing the bean to it.

Can be used together with with, withCondition, alias and fetchAs.

Parameters

$property
property
$function
function
$maxDepth
maximum depth for traversal

Returns

RedBeanPHP\OODBBean

Throws

RedBeanPHP\RedException
public integer
# count( )

Implementation of Countable interface. Makes it possible to use count() function on a bean.

Implementation of Countable interface. Makes it possible to use count() function on a bean.

Returns

integer

Implementation of

Countable::count()
public boolean
# isEmpty( )

Checks whether a bean is empty or not. A bean is empty if it has no other properties than the id field OR if all the other property are empty().

Checks whether a bean is empty or not. A bean is empty if it has no other properties than the id field OR if all the other property are empty().

Returns

boolean
public RedBeanPHP\OODBBean
# setAttr( string $property, mixed $value )

Chainable setter.

Chainable setter.

Parameters

$property
the property of the bean
$value
the value you want to set

Returns

RedBeanPHP\OODBBean
public RedBeanPHP\OODBBean
# unsetAll( array $properties )

Comfort method. Unsets all properties in array.

Comfort method. Unsets all properties in array.

Parameters

$properties
properties you want to unset.

Returns

RedBeanPHP\OODBBean
public mixed
# old( string $property )

Returns original (old) value of a property. You can use this method to see what has changed in a bean.

Returns original (old) value of a property. You can use this method to see what has changed in a bean.

Parameters

$property
name of the property you want the old value of

Returns

mixed
public boolean
# isTainted( )

Convenience method. Returns TRUE if the bean has been changed, or FALSE otherwise. Same as $bean->getMeta('tainted'); Note that a bean becomes tainted as soon as you retrieve a list from the bean. This is because the bean lists are arrays and the bean cannot determine whether you have made modifications to a list so RedBeanPHP will mark the whole bean as tainted.

Convenience method. Returns TRUE if the bean has been changed, or FALSE otherwise. Same as $bean->getMeta('tainted'); Note that a bean becomes tainted as soon as you retrieve a list from the bean. This is because the bean lists are arrays and the bean cannot determine whether you have made modifications to a list so RedBeanPHP will mark the whole bean as tainted.

Returns

boolean
public boolean
# hasChanged( string $property )

Returns TRUE if the value of a certain property of the bean has been changed and FALSE otherwise.

Returns TRUE if the value of a certain property of the bean has been changed and FALSE otherwise.

Note that this method will return TRUE if applied to a loaded list. Also note that this method keeps track of the bean's history regardless whether it has been stored or not. Storing a bean does not undo it's history, to clean the history of a bean use: clearHistory().

Parameters

$property
name of the property you want the change-status of

Returns

boolean
public boolean
# hasListChanged( string $property )

Returns TRUE if the specified list exists, has been loaded and has been changed: beans have been added or deleted. This method will not tell you anything about the state of the beans in the list.

Returns TRUE if the specified list exists, has been loaded and has been changed: beans have been added or deleted. This method will not tell you anything about the state of the beans in the list.

Parameters

$property
name of the list to check

Returns

boolean
public RedBeanPHP\OODBBean
# clearHistory( )

Clears (syncs) the history of the bean. Resets all shadow values of the bean to their current value.

Clears (syncs) the history of the bean. Resets all shadow values of the bean to their current value.

Returns

RedBeanPHP\OODBBean
public RedBeanPHP\OODBBean
# link( string|RedBeanPHP\OODBBean $typeOrBean, string|array $qualification = array() )

Creates a N-M relation by linking an intermediate bean. This method can be used to quickly connect beans using indirect relations. For instance, given an album and a song you can connect the two using a track with a number like this:

Creates a N-M relation by linking an intermediate bean. This method can be used to quickly connect beans using indirect relations. For instance, given an album and a song you can connect the two using a track with a number like this:

Usage:

$album->link('track', array('number'=>1))->song = $song;

or:

$album->link($trackBean)->song = $song;

What this method does is adding the link bean to the own-list, in this case ownTrack. If the first argument is a string and the second is an array or a JSON string then the linking bean gets dispensed on-the-fly as seen in example #1. After preparing the linking bean, the bean is returned thus allowing the chained setter: ->song = $song.

Parameters

$typeOrBean
$type type of bean to dispense or the full bean
$qualification
JSON string or array (optional)

Returns

RedBeanPHP\OODBBean
public RedBeanPHP\OODBBean
# one( $type )

Returns a bean of the given type with the same ID of as the current one. This only happens in a one-to-one relation. This is as far as support for 1-1 goes in RedBeanPHP. This method will only return a reference to the bean, changing it and storing the bean will not update the related one-bean.

Returns a bean of the given type with the same ID of as the current one. This only happens in a one-to-one relation. This is as far as support for 1-1 goes in RedBeanPHP. This method will only return a reference to the bean, changing it and storing the bean will not update the related one-bean.

Returns

RedBeanPHP\OODBBean
public RedBeanPHP\OODBBean
# fresh( )

Returns the same bean freshly loaded from the database.

Returns the same bean freshly loaded from the database.

Returns

RedBeanPHP\OODBBean
public RedBeanPHP\OODBBean
# via( string $via )

Registers a association renaming globally.

Registers a association renaming globally.

Parameters

$via
type you wish to use for shared lists

Returns

RedBeanPHP\OODBBean
public integer
# countOwn( string $type )

Counts all own beans of type $type. Also works with alias(), with() and withCondition().

Counts all own beans of type $type. Also works with alias(), with() and withCondition().

Parameters

$type
the type of bean you want to count

Returns

integer
public integer
# countShared( string $type )

Counts all shared beans of type $type. Also works with via(), with() and withCondition().

Counts all shared beans of type $type. Also works with via(), with() and withCondition().

Parameters

$type
type of bean you wish to count

Returns

integer
public array &
# aggr( string $list, string $property, string $type = NULL )

Iterates through the specified own-list and fetches all properties (with their type) and returns the references. Use this method to quickly load indirectly related beans in an own-list. Whenever you cannot use a shared-list this method offers the same convenience by aggregating the parent beans of all children in the specified own-list.

Iterates through the specified own-list and fetches all properties (with their type) and returns the references. Use this method to quickly load indirectly related beans in an own-list. Whenever you cannot use a shared-list this method offers the same convenience by aggregating the parent beans of all children in the specified own-list.

Example:

$quest->aggr( 'xownQuestTarget', 'target', 'quest' );

Loads (in batch) and returns references to all quest beans residing in the $questTarget->target properties of each element in the xownQuestTargetList.

Parameters

$list
the list you wish to process
$property
the property to load
$type
the type of bean residing in this property (optional)

Returns

array
public boolean
# equals( RedBeanPHP\OODBBean $bean )

Tests whether the database identities of two beans are equal.

Tests whether the database identities of two beans are equal.

Parameters

$bean
other bean

Returns

boolean
public array
# jsonSerialize( )

Magic method jsonSerialize, implementation for the \JsonSerializable interface, this method gets called by json_encode and facilitates a better JSON representation of the bean. Exports the bean on JSON serialization, for the JSON fans.

Magic method jsonSerialize, implementation for the \JsonSerializable interface, this method gets called by json_encode and facilitates a better JSON representation of the bean. Exports the bean on JSON serialization, for the JSON fans.

Returns

array

See

http://php.net/manual/en/class.jsonserializable.php
Constants summary
boolean C_ERR_IGNORE

FUSE error modes.

FUSE error modes.

# FALSE
integer C_ERR_LOG
# 1
integer C_ERR_NOTICE
# 2
integer C_ERR_WARN
# 3
integer C_ERR_EXCEPTION
# 4
integer C_ERR_FUNC
# 5
integer C_ERR_FATAL
# 6
Properties summary
protected static boolean $errorHandlingFUSE
# FALSE
protected static callable|null $errorHandler
# NULL
protected static array $aliases
# array()
protected static boolean $autoResolve
# FALSE
protected array $properties

This is where the real properties of the bean live. They are stored and retrieved by the magic getter and setter (__get and __set).

This is where the real properties of the bean live. They are stored and retrieved by the magic getter and setter (__get and __set).

# array()
protected array $__info

Here we keep the meta data of a bean.

Here we keep the meta data of a bean.

# array()
protected RedBeanPHP\BeanHelper $beanHelper

The BeanHelper allows the bean to access the toolbox objects to implement rich functionality, otherwise you would have to do everything with R or external objects.

The BeanHelper allows the bean to access the toolbox objects to implement rich functionality, otherwise you would have to do everything with R or external objects.

# NULL
protected null $fetchType
# NULL
protected string $withSql
# ''
protected array $withParams
# array()
protected string $aliasName
# NULL
protected string $via
# NULL
protected boolean $noLoad
# FALSE
protected boolean $all
# FALSE
API documentation generated by ApiGen