1. Go to this page and download the library: Download crutch/database-pdo 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/ */
crutch / database-pdo example snippets
/** @var \PDO $pdo */
$database = new \Crutch\DatabasePdo\DatabasePdo($pdo);
$database->execute('INSERT INTO table (id, value) VALUES (?, ?)', [1, 'it is works']);
$query = 'SELECT * FROM table WHERE id = ?';
$oneRow = $database->fetch($query, [1]);
// $oneRow = ['id' => 1, 'value' => 'it is works'];
$allRows = $database->fetchAll($query, [1]);
// $allRows = [['id' => 1, 'value' => 'it is works']];
$database->begin();
try {
$database->execute('DELETE FROM table WHERE id = :id', ['id' => 1]);
$database->commit();
} catch (\Crutch\Database\Exception\StorageError $exception) {
$database->rollback();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.