1. Go to this page and download the library: Download neoan3-apps/db 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/ */
neoan3-apps / db example snippets
// SELECT name FROM user WHERE id = 1
// returns e.g.: [0=>['name'=>'Adam']]
$user = Db::easy('user.name',['id'=>1]);
// UPDATE user SET name = 'Sam', email = '[email protected]' WHERE id = 1
$update = ['name'=>'Sam','email'=>'[email protected]'];
Db::user($update, ['id'=>1]);
/*
* When using Db::setEnvironment() the prepended 'db_' is ommitted.
*/
// set single variable:
Db::setEnvironment('name','test_db');
// set multiple variables:
Db::setEnvironment(['name'=>'test_db','password'=>'FooBar']);
// SELECT first_name, last_name FROM user
Db::easy('user.first_name user.last_name');
// SELECT
// user.first_name,
// user.last_name,
// user_email.email,
// user_password.confirm_date
// FROM user
// JOIN user_email ON user_email.user_id = user.id
// JOIN user_password ON user_password.user_id = user.id
Db::easy('user.first_name user.last_name user_email.email user_password.confirm_date');