1. Go to this page and download the library: Download twoleds/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/ */
twoleds / database-pdo example snippets
$database = new PDODatabase("... pdo dsn", "user", "password", [
// ... pdo attributes
]);
$userId = $database->insert(
'INSERT INTO user (name, email) VALUES (?, ?)',
'Spike',
'[email protected]'
);
$users = $database->select(
'SELECT * FROM user WHERE email LIKE ?',
'%@example.com'
);
$count = $database->selectField(
'SELECT COUNT(*) FROM user WHERE email LIKE ?',
'%@example.com'
);
$user = $database->selectRow(
'SELECT * FROM user WHERE id = ?',
123
);
$database->update(
'UPDATE user SET name = ? WHERE id = ?',
'Xavier',
123
);
$database->update(
'DELETE user WHERE id = ?',
123
);
$database->transactional(function ($database) {
$counter = $database->selectField(
'SELECT counter FROM user WHERE id = ? FOR UPDATE',
123
);
$counter = $counter + 1;
$database->update(
'UPDATE user SET counter = ? WHERE id = ?',
123
);
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.