1. Go to this page and download the library: Download itools/zendb 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/ */
itools / zendb example snippets
use Itools\ZenDB\DB;
// Connect
DB::connect([
'hostname' => 'localhost',
'username' => 'dbuser',
'password' => 'secret',
'database' => 'my_app',
'tablePrefix' => 'app_', // optional
]);
// Select rows
$users = DB::select('users', "status = ?", 'active');
foreach ($users as $user) {
echo "Hello, $user->name!"; // auto HTML-encoded
}
// Get a single row
$user = DB::selectOne('users', "id = ?", 1);
// Insert a row
$newId = DB::insert('users', [
'name' => 'Alice',
'city' => 'Vancouver',
]);
// Update a row
$newValues = ['city' => 'Toronto'];
$where = ['id' => $newId]; // arrays work too
DB::update('users', $newValues, $where);
// Delete a row
DB::delete('users', ['id' => $newId]);
// Full SQL when you need it (:: inserts your table prefix)
$rows = DB::query("SELECT name, city FROM ::users WHERE status = :status AND city = :city", [
':status' => 'active',
':city' => 'Vancouver',
]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.