1. Go to this page and download the library: Download underpin/berlindb-extension library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
underpin / berlindb-extension example snippets
underpin()->berlin_db()->add( 'example', [
'table' => 'Namespace\To\Berlin_DB\Table',
'schema' => 'Namespace\To\Berlin_DB\Schema',
'query' => 'Namespace\To\Berlin_DB\Query',
'name' => 'Human Readable Table Name',
'description' => 'Description of the purpose of this table',
'sanitize_callback' => function( $key, $value ){
// Function to sanitize fields before saving.
}
] );
// Run a query using the specified model
underpin()->berlin_db()->get('example')->query([/*...*/]);
// Get table object
underpin()->berlin_db()->get('example')->table();
// Get schema
underpin()->berlin_db()->get('example')->schema();
// Automatically sanitize, and then create/update a record.
// If the provided arguments ample')->save( [/*...*/] );
// Delete a record
$deleted = underpin()->berlin_db()->get('example')->delete( $id );
// Install all tables
underpin()->berlin_db()->install();
// Reset all tables
underpin()->berlin_db()->reset();
// Delete all tables
underpin()->berlin_db()->uninstall();
// Meta Table
underpin()->berlin_db()->add( 'example-meta-table', [
'table' => 'Namespace\To\Berlin_DB\Table',
'schema' => 'Namespace\To\Berlin_DB\Schema',
'query' => 'Namespace\To\Berlin_DB\Query',
'name' => 'Human Readable Table Name',
'description' => 'Description of the purpose of this table',
'sanitize_callback' => function( $key, $value ){
// Function to sanitize fields before saving.
}
] );
// Table
underpin()->berlin_db()->add( 'example', [
'class' => 'Underpin_BerlinDB\Factories\Database_Model_With_Meta_Instance',
'args' => [
'table' => 'Namespace\To\Berlin_DB\Table',
'schema' => 'Namespace\To\Berlin_DB\Schema',
'query' => 'Namespace\To\Berlin_DB\Query',
'name' => 'Human Readable Table Name',
'description' => 'Description of the purpose of this table',
'sanitize_callback' => function( $key, $value ){
// Function to sanitize fields before saving.
},
'get_meta_table_callback' => function(){
return underpin()->berlin_db()->get('example-meta-table');
}
]
] );