1. Go to this page and download the library: Download h2lsoft/db-manager 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/ */
h2lsoft / db-manager example snippets
use \h2lsoft\DBManager;
$DBM = new DBManager\DBManager(); // soft mode is activated by default
$DBM->connect('mysql', 'localhost', 'root', '', 'mydatabase');
// execute simple query with binding
$sql = "SELECT Name, SurfaceArea FROM Country WHERE Continent = :Continent AND deleted = 'NO' ORDER BY SurfaceArea DESC LIMIT 3";
$results = $DBM->query($sql, [':Continent' => 'Asia'])->fetchAll();
// or use short version
$sql = $DBM->select("Name, SurfaceArea")
->from('Country')
->where("Continent = :Continent")
->orderBy('SurfaceArea DESC')
->limit(3)
->getSQL();
$results = $DBM->query($sql, [':Continent' => 'Asia'])->fetchAll();
// or imbricated version
$results = $DBM->select("Name, SurfaceArea")
->from('Country')
->where("Continent = :Continent")
->orderBy('SurfaceArea DESC')
->limit(3)
->executeSql([':Continent' => 'Asia'])
->fetchAll();
// insert
$values = [];
$values['Name'] = "Agatha Christies";
$values['Birthdate'] = "1890-10-15";
$ID = $DBM->table('Author')->insert($values);
// update
$values = [];
$values['Name'] = "Agatha Christies";
$affected_rows = $DBM->table('Author')->update($values, $ID); # you can put direct ID or you can use where clause
// delete
$affected_rows = $DBM->table('Author')->delete(["ID = ?", $ID]);
// get a record by ID, you can use multiple ID by array
$record = $DBM->table('Country')->getByID(10);
// multiple ID
$records = $DBM->table('Country')->getByID([12, 10, 55]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.