Download the PHP package underpin/berlindb-extension without Composer
On this page you can find all versions of the php package underpin/berlindb-extension. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download underpin/berlindb-extension
More information about underpin/berlindb-extension
Files in underpin/berlindb-extension
Package berlindb-extension
Short Description BerlinDB Implementation for Underpin
License GPL-2.0-or-later
Informations about the package berlindb-extension
Underpin BerlinDB Extension
BerlinDB Integration for the Underpin WordPress framework.
A few key benefits:
- Tables are registered through a
Database_Model
class. This class provides useful context that makes working with BerlinDB a little easier helps keep your code DRY. - All tables are stored in a registry. This allows you to interact with all tables at one time. Need to uninstall everything? You can do that with a single method, instead of manually looping through tables.
- All CRUD actions happen through database model instead of creating
Query
instances everywhere.
Installation
Using Composer
composer require underpin/berlindb-extension
Manually
This plugin uses a built-in autoloader, so as long as BerlinDB is required before this extension, it should work as-expected.
require_once(__DIR__ . '/underpin-berlin-db/underpin-berlin-db.php');
Setup
- Install BerlinDB
- Install Underpin. See Underpin Docs
- Create BerlinDB classes.
- Register new database models as-needed.
Example
If you currently have all BerlinDB classes built, you can reference them directly like-so. This will create a new database
model called example
, which can be referenced with underpin()->berlin_db()->get('example')
.
Alternatively, you can extend Database_Model
and reference the extended class directly, like so:
Working With the Model
Once registered, you can access any of the classes inside the model using the various helper methods.
Creating, Updating, and Deleting
The model includes a handful of helper functions to make it a little easier to update data.
Table Setup
Meta Tables
If a database model also has a meta table, it is possible to instruct the model to make that table accessible in the
model. To-do this, you simply have to use the Database_Model_With_Meta_Instance
when registering your model.
Alternatively, you can extend Database_Model
, use the With_Meta
trait, and then reference the extended class directly,
like so:
With this setup, you now have access to a few other methods from within the example
model's context.