1. Go to this page and download the library: Download dimns/simplepdo 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/ */
dimns / simplepdo example snippets
// Init class for MySQL (default port 3306)
$db = new DimNS\SimplePDO\MySQL('server', 'dbname', 'username', 'password');
// Or init class for MySQL (override port)
$db = new DimNS\SimplePDO\MySQL('server', 'dbname', 'username', 'password', 3307);
// Or init class for SQLite
$db = new DimNS\SimplePDO\SQLite('/path/to/database/file.sqlite');
// Query without prepared variables
$result = $db->query('SELECT `field1`, `field2` FROM `table`');
echo '<pre>';
print_r($result);
echo '</pre>';
// Query with prepared variables
$result = $db->query('INSERT INTO `table` SET
`field1` = :field1,
`field2` = :field2
', [
'field1' => 'Simple string',
'field2' => 123,
]);
echo $result;
// Transaction (only for mysql innodb table)
$result = $db->transaction([
[
'query' => 'INSERT INTO `table` SET `field1` = :field1, `field2` = :field2, `field3` = :field3',
'data' => [
'field1' => 'val1',
'field2' => 'val2',
'field3' => 'val3',
],
], [
'query' => 'UPDATE `table` SET `field1` = :field1 WHERE `field2` > :field2',
'data' => [
'field1' => 'val1',
'field2' => 'val2',
],
],
]);
echo '<pre>';
print_r($result);
echo '</pre>';
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.