1. Go to this page and download the library: Download maggsweb/maggsweb-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/ */
$sql = "SELECT * FROM `names`";
$db->query($sql);
$results = $db->fetchAll(); // Multiple rows, returned and an Object Array
$results = $db->fetchAll('Array'); // Multiple rows, returned as a multi-dimensional array
$sql = "SELECT * FROM `names` LIMIT 1";
$db->query($sql);
$result = $db->fetchRow(); // Single row, returned as an Object
$result = $db->fetchRow('Array'); // Single row, returned as an Array
$sql = "SELECT name FROM `names` LIMIT 1";
$db->query($sql);
$result = $db->fetchOne(); // Single value, returned as a String
$sql = "SELECT * FROM `names` WHERE firstname = :firstname";
$db->query($sql);
$db->bind(':firstname', 'Chris');
$results = $db->fetchAll();
// or
$results = $db->query("SELECT * FROM `names` WHERE firstname = :firstname")
->bind(':firstname', 'Chris')
->fetchAll();
if ($results) {
foreach ($results as $result) {
echo $result->{$column};
}
} else {
echo $db->getError();
}