1. Go to this page and download the library: Download greg0/lazer-database 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/ */
greg0 / lazer-database example snippets
define('LAZER_DATA_PATH', realpath(__DIR__).'/data/'); //Path to folder with tables
$row = Lazer::table('table_name')->find(1); //Edit row with ID 1
$row->nickname = 'edited_user'; // or $row->setField('nickname', 'edited_user')
$row->save();
$row = Lazer::table('table_name')->find(1); //Edit row with ID 1
$row->set(array(
'nickname' => 'user',
'email' => '[email protected]'
));
$row->save();
Lazer::table('table_name')->find(1)->delete(); //Will remove row with ID 1
// OR
Lazer::table('table_name')->where('name', '=', 'John')->find()->delete(); //Will remove John from DB
Relation::table('table1')->belongsTo('table2')->localKey('table2_id')->foreignKey('id')->setRelation();
Relation::table('table2')->hasMany('table1')->localKey('id')->foreignKey('table2_id')->setRelation();
Relation::table('table2')->hasAndBelongsToMany('table1')->localKey('id')->foreignKey('id')->setRelation(); // Junction table will be crete automaticly