1. Go to this page and download the library: Download cb-master/cbm-model 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/ */
cb-master / cbm-model example snippets
use CBM\Model\Model;
// Require Autoload File
r' => 'mysql',
'host' => 'localhost',
'name' => 'database_name',
'user' => 'database_user_here',
'password' => 'database_password_here'
]);
// Add 'port' Key if you are not using the default port.
/**
* Model::config([
* 'driver' => 'mysql',
* 'host' => 'localhost',
* 'port' => 12345,
* 'name' => 'database_name',
* 'user' => 'database_user_here',
* 'password' => 'database_password_here',
* ])
* */
// Config DB Model
Model::config([
'host' => 'localhost',
'name' => 'database_name',
'user' => 'database_user_here',
'password' => 'database_password_here',
]);
// Get All Data With Select *
Model::table('table_name')->get();
// Get All Data With Selected Columns
Model::table('table_name')->get('column_1, column_2, column_3, .....');
// Get Single Data
Model::table('table_name')->single();
// Get All Data
Model::table('table_name')->where(['status'=>'active'])->get();
// Get All Data With Multiple Array Keys
Model::table('table_name')->where(['status'=>'active', 'email'=>'verified'])->get();
// Get Data With Multiple where() method.
Model::table('table_name')->where(['status'=>'active'])->where(['id'=>10], '>')->get();
// Get All Data Between min and max
Model::table('table_name')->between('id', 1, 10)->get();
// Get All Data Between min and max with multiple condition
Model::table('table_name')->between('id', 1, 10)->between('id', 50, 60)->get();
// Get Data for Default Limit 20
Model::table('table_name')->limit()->get();
// Get Data for Default Limit 20 With Offset
Model::table('table_name')->limit()->offset(0)->get();
// Custom Limit Set
Model::table('table_name')->limit(40)->get();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.