Methods summary
protected
|
|
protected
array
|
#
processGroups( array $originals, array $current, array $additions, array $trashcan, array $residue )
Process groups. Internal function. Processes different kind of groups for
storage function. Given a list of original beans and a list of current beans,
this function calculates which beans remain in the list (residue), which
have been deleted (are in the trashcan) and which beans have been added
(additions).
Process groups. Internal function. Processes different kind of groups for
storage function. Given a list of original beans and a list of current beans,
this function calculates which beans remain in the list (residue), which
have been deleted (are in the trashcan) and which beans have been added
(additions).
Parameters
- $originals
- originals
- $current
- the current beans
- $additions
- beans that have been added
- $trashcan
- beans that have been deleted
- $residue
- beans that have been left untouched
Returns
array
|
protected
integer
|
|
protected
|
#
processSharedAdditions( RedBeanPHP\OODBBean $bean, array $sharedAdditions )
Processes a list of beans from a bean. A bean may contain lists. This
method handles shared addition lists; i.e. the $bean->sharedObject properties.
Processes a list of beans from a bean. A bean may contain lists. This
method handles shared addition lists; i.e. the $bean->sharedObject properties.
Parameters
- $bean
- the bean
- $sharedAdditions
- list with shared additions
|
protected
|
#
processResidue( RedBeanPHP\OODBBean $ownresidue, array $ownresidue,… )
Processes a list of beans from a bean. A bean may contain lists. This
method handles own lists; i.e. the $bean->ownObject properties.
A residue is a bean in an own-list that stays where it is. This method
checks if there have been any modification to this bean, in that case
the bean is stored once again, otherwise the bean will be left untouched.
Processes a list of beans from a bean. A bean may contain lists. This
method handles own lists; i.e. the $bean->ownObject properties.
A residue is a bean in an own-list that stays where it is. This method
checks if there have been any modification to this bean, in that case
the bean is stored once again, otherwise the bean will be left untouched.
Parameters
- $ownresidue
- $bean bean tor process
- $ownresidue,…
- list to process
|
protected
|
#
processTrashcan( RedBeanPHP\OODBBean $bean, array $ownTrashcan )
Processes a list of beans from a bean. A bean may contain lists. This
method handles own lists; i.e. the $bean->ownObject properties.
A trash can bean is a bean in an own-list that has been removed
(when checked with the shadow). This method
checks if the bean is also in the dependency list. If it is the bean will be removed.
If not, the connection between the bean and the owner bean will be broken by
setting the ID to NULL.
Processes a list of beans from a bean. A bean may contain lists. This
method handles own lists; i.e. the $bean->ownObject properties.
A trash can bean is a bean in an own-list that has been removed
(when checked with the shadow). This method
checks if the bean is also in the dependency list. If it is the bean will be removed.
If not, the connection between the bean and the owner bean will be broken by
setting the ID to NULL.
Parameters
- $bean
- bean to process
- $ownTrashcan
- list to process
|
protected
|
#
processSharedTrashcan( RedBeanPHP\OODBBean $bean, array $sharedTrashcan )
Unassociates the list items in the trashcan.
Unassociates the list items in the trashcan.
Parameters
- $bean
- bean to process
- $sharedTrashcan
- list to process
|
protected
|
#
processSharedResidue( RedBeanPHP\OODBBean $bean, array $sharedresidue )
Stores all the beans in the residue group.
Stores all the beans in the residue group.
Parameters
- $bean
- bean to process
- $sharedresidue
- list to process
|
protected
boolean
|
#
hasListsOrObjects( RedBeanPHP\OODBBean $bean )
Determines whether the bean has 'loaded lists' or
'loaded embedded beans' that need to be processed
by the store() method.
Determines whether the bean has 'loaded lists' or
'loaded embedded beans' that need to be processed
by the store() method.
Parameters
- $bean
- bean to be examined
Returns
boolean
|
protected
|
#
processEmbeddedBean( array & $embeddedBeans, RedBeanPHP\OODBBean $bean, string $property, RedBeanPHP\OODBBean $value )
Converts an embedded bean to an ID, removed the bean property and
stores the bean in the embedded beans array.
Converts an embedded bean to an ID, removed the bean property and
stores the bean in the embedded beans array.
Parameters
- $embeddedBeans
- destination array for embedded bean
- $bean
- target bean to process
- $property
- property that contains the embedded bean
- $value
- embedded bean itself
|
public
|
#
__construct( RedBeanPHP\OODB $oodb, RedBeanPHP\QueryWriter $writer )
Constructor, requires a query writer.
Creates a new instance of the bean respository class.
Constructor, requires a query writer.
Creates a new instance of the bean respository class.
Parameters
- $oodb
- $writer the Query Writer to use for this repository
- $writer
|
public
|
#
check( RedBeanPHP\OODBBean $bean )
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.
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.
Parameters
- $bean
- the bean that needs to be checked
|
public
array
|
#
find( string $type, array $conditions = array(), string $sql = NULL, array $bindings = array() )
Searches the database for a bean that matches conditions $conditions and sql $addSQL
and returns an array containing all the beans that have been found.
Searches the database for a bean that matches conditions $conditions and sql $addSQL
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.
Parameters
- $type
- type of beans you are looking for
- $conditions
- list of conditions
- $sql
- $addSQL SQL to be used in query
- $bindings
- whether you prefer to use a WHERE clause or not (TRUE = not)
Returns
array
|
public
RedBeanPHP\BeanCollection
|
#
findCollection( string $type, string $sql, array $bindings = array() )
Finds a BeanCollection.
Parameters
- $type
- type of beans you are looking for
- $sql
- SQL to be used in query
- $bindings
- whether you prefer to use a WHERE clause or not (TRUE = not)
Returns
|
public
integer|string
|
#
store( RedBeanPHP\OODBBean |RedBeanPHP\SimpleModel $bean )
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.
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).
Parameters
Returns
integer|string
|
public
array
|
#
batch( string $type, array $ids )
Returns an array of beans. Pass a type and a series of ids and
this method will bring you the corresponding beans.
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.
Parameters
- $type
- type of beans
- $ids
- ids to load
Returns
array
|
public
array
|
#
convertToBeans( string $type, array $rows, string $mask = NULL )
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.
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.
New in 4.3.2: meta mask. The meta mask is a special mask to send
data from raw result rows to the meta store of the bean. This is
useful for bundling additional information with custom queries.
Values of every column whos name starts with $mask will be
transferred to the meta section of the bean under key 'data.bundle'.
Parameters
- $type
- type of beans you would like to have
- $rows
- rows from the database result
- $mask
- meta mask to apply (optional)
Returns
array
|
public
integer
|
#
count( string $type, string $addSQL = '', array $bindings = array() )
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.
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.
Parameters
- $type
- type of bean we are looking for
- $addSQL
- additional SQL snippet
- $bindings
- parameters to bind to SQL
Returns
integer
|
public
|
#
trash( RedBeanPHP\OODBBean |RedBeanPHP\SimpleModel $bean )
Removes a bean from the database.
This function will remove the specified OODBBean
Bean Object from the database.
Removes a bean from the database.
This function will remove the specified OODBBean
Bean Object from the database.
Parameters
- $bean
- bean you want to remove from database
|
public
boolean
|
#
tableExists( string $table )
Checks whether the specified table already exists in the database.
Not part of the Object Database interface!
Checks whether the specified table already exists in the database.
Not part of the Object Database interface!
Deprecated
Use AQueryWriter::typeExists() instead.
Parameters
Returns
boolean
|
public
boolean
|
#
wipe( string $type )
Trash all beans of a given type. Wipes an entire type of bean.
Trash all beans of a given type. Wipes an entire type of bean.
Parameters
- $type
- type of bean you wish to delete all instances of
Returns
boolean
|