1. Go to this page and download the library: Download tschoffelen/db.php 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/ */
tschoffelen / db.php example snippets
$db = new Database($database_name, $username, $password, $host); // $host is optional and defaults to 'localhost'
// set amount per pack to 5 for all Kitkats
$db->update(
'candy', [
// fields to be updated
'amount_per_pack' => 5
], [
// 'WHERE' clause
'brand' => 'Kitkat'
]
);
// Global scope
$db = new Database($database_name, $username, $password, $host);
// Function scope
function something() {
// We could simply use `global $db;`, but using globals is bad. Instead we can do this:
$db = Database::instance();
// And now we have access to $db inside the function
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.