1. Go to this page and download the library: Download sinevia/php-library-sqldb 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/ */
sinevia / php-library-sqldb example snippets
// MySQL
$db = new Sinevia\SqlDB(array(
'database_type'=>'mysql',
'database_name'=>'db_name',
'database_host'=>'db_host',
'database_user'=>'db_user',
'database_pass'=>'db_pass'
));
// SQLite (creating a new SQLite database, if it does not exist)
$db = new Sinevia\SqlDB(array(
'database_type'=>'sqlite',
'database_name'=>'db_name',
'database_host'=>'db_host',
'database_user'=>'db_user',
'database_pass'=>'db_pass'
));
// SQLiteDB (SQLite in the cloud)
$db = new Sinevia\SqlDB(array(
'database_type'=>'sqlitedb',
'database_host'=>'sqlitedb_api_url',
'database_pass'=>'sqlitedb_api_key'
));
// Using existing PDO instance
$db = new Sinevia\SqlDB($pdo);
// Dropping a table
$isOk = $db->table("person")->drop();
$isOk = $db->table('person')->insert([
'FirstName' => 'Peter',
'LastName' => 'Pan',
]);
// Getting the new autoincremented ID
$personId = $db->lastInsertId();
//Selects all the rows from the table
$rows = $db->table("person")->select();
// Selects the rows where the column NAME is different from Peter, in descending order
$rows = $db->table("person")
->where("Name", "!=", "Peter")
->orderby("Name","desc")
->select();
// Delete row by ID
$isOk = $db->table("person")
->where("Id", "==", "1")
->update([
'LastName' => 'Voldemort'
]);
// Delete row by ID
$isOk = $db->table("person")
->where("Id", "==", "1")
->delete();
// Delete all rows in the table
$isOk = $db->table("person")->delete();