Toolbox

From RedBean

Jump to: navigation, search

Contents

The RedBean Toolbox

The toolbox class in RedBean acts as a resource locator; its main function is to provide tools you often need. I could have stashed all functionality in one big object (oodb) but I want this library to be clean and maintainable. So I have given each class its own piece of logic and with that its own responsibility. A class in the RedBean realm has therefore only one reason to change. For you this means that the Kickstarter (who likes to make your job easier) returns a toolbox instead of a RedBean instance. Inside this toolbox you will find three classes that make up the core of RedBean.

The Adapter

The adapter is the class that communicates with the database for RedBean. This adapter makes it possible to execute queries to manipulate the database. To get an instance of this adapter use:

$adapter = $toolbox->getDatabaseAdapter();

For more information on the adapter see chapter: Queries.

The Query Writer

The Query Writer is only used by some RedBean modules to write platform specific SQL. You never have to use this in your own code but by providing the toolbox to other modules you give them the opportunity to take advantage of this system.

RedBean OODB

Most of the time you will need to interact with the RedBean Core Class instance. This object represents the object oriented database that RedBean as a whole tries to simulate. To pick this tool out of the toolbox say:

$redbean = $toolbox->getRedBean();

But if you have read the previous chapters carefully you would already have seen this :) .

Personal tools