\RedBeanPHPToolBox

ToolBox.

The toolbox is an integral part of RedBeanPHP providing the basic architectural building blocks to manager objects, helpers and additional tools like plugins. A toolbox contains the three core components of RedBeanPHP: the adapter, the query writer and the core functionality of RedBeanPHP in OODB.

Summary

Methods
Properties
Constants
__construct()
getWriter()
getRedBean()
getDatabaseAdapter()
No public properties found
No constants found
No protected methods found
$oodb
$writer
$adapter
N/A
No private methods found
No private properties found
N/A

Properties

Methods

__construct()

__construct(\RedBeanPHP\OODB  $oodb, \RedBeanPHP\Adapter\DBAdapter  $adapter, \RedBeanPHP\QueryWriter  $writer) 

Constructor.

The toolbox is an integral part of RedBeanPHP providing the basic architectural building blocks to manager objects, helpers and additional tools like plugins. A toolbox contains the three core components of RedBeanPHP: the adapter, the query writer and the core functionality of RedBeanPHP in OODB.

Usage:

$toolbox = new ToolBox( $oodb, $adapter, $writer ); $plugin = new MyPlugin( $toolbox );

The example above illustrates how the toolbox is used. The core objects are passed to the ToolBox constructor to assemble a toolbox instance. The toolbox is then passed to the plugin, helper or manager object. Instances of TagManager, AssociationManager and so on are examples of this, they all require a toolbox. The toolbox can also be obtained from the facade using: R::getToolBox();

Parameters

\RedBeanPHP\OODB $oodb

Object Database, OODB

\RedBeanPHP\Adapter\DBAdapter $adapter

Database Adapter

\RedBeanPHP\QueryWriter $writer

Query Writer

getWriter()

getWriter() : \RedBeanPHP\QueryWriter

Returns the query writer in this toolbox.

The Query Writer is responsible for building the queries for a specific database and executing them through the adapter.

Usage:

$toolbox = R::getToolBox(); $redbean = $toolbox->getRedBean(); $adapter = $toolbox->getDatabaseAdapter(); $writer = $toolbox->getWriter();

The example above illustrates how to obtain the core objects from a toolbox instance. If you are working with the R-object only, the following shortcuts exist as well:

  • R::getRedBean()
  • R::getDatabaseAdapter()
  • R::getWriter()

Returns

\RedBeanPHP\QueryWriter

getRedBean()

getRedBean() : \RedBeanPHP\OODB

Returns the OODB instance in this toolbox.

OODB is responsible for creating, storing, retrieving and deleting single beans. Other components rely on OODB for their basic functionality.

Usage:

$toolbox = R::getToolBox(); $redbean = $toolbox->getRedBean(); $adapter = $toolbox->getDatabaseAdapter(); $writer = $toolbox->getWriter();

The example above illustrates how to obtain the core objects from a toolbox instance. If you are working with the R-object only, the following shortcuts exist as well:

  • R::getRedBean()
  • R::getDatabaseAdapter()
  • R::getWriter()

Returns

\RedBeanPHP\OODB

getDatabaseAdapter()

getDatabaseAdapter() : \RedBeanPHP\Adapter\DBAdapter

Returns the database adapter in this toolbox.

The adapter is responsible for executing the query and binding the values. The adapter also takes care of transaction handling.

Usage:

$toolbox = R::getToolBox(); $redbean = $toolbox->getRedBean(); $adapter = $toolbox->getDatabaseAdapter(); $writer = $toolbox->getWriter();

The example above illustrates how to obtain the core objects from a toolbox instance. If you are working with the R-object only, the following shortcuts exist as well:

  • R::getRedBean()
  • R::getDatabaseAdapter()
  • R::getWriter()

Returns

\RedBeanPHP\Adapter\DBAdapter