1. Go to this page and download the library: Download phpgt/database 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/ */
phpgt / database example snippets
$userRow = $db->fetch("user/getById", 105);
// "fetchAll" method returns an iterable ResultSet of Row objects.
$bookResultSet = $db->fetchAll("shopitem/getItemsInCategory", "books");
foreach($bookResultSet as $bookRow) {
echo "Book title: ", $bookRow->getString("title"), PHP_EOL;
echo "Book price: £", ($bookRow->getFloat("price") + $bookRow->getFloat("vat")), PHP_EOL;
if($bookRow->offerEnds) {
echo "Item on offer until: ", $bookRow->getDateTime("offerEnds")->format("dS M Y");
}
}
// "Create" method always returns the last inserted ID:
$newCustomerId = $db->create("customer/new", [
"first_name" => "Marissa",
"last_name" => "Mayer",
"dob" => new DateTime("1975-05-30"),
]);
// "Update" or "delete" methods always return the number of affected rows:
$numberOfItemsAffected = $db->update("shop/item/increasePrice", [
"percent" => 12.5,
"max_increase" => 20.00,
]);
$numberOfDeletedReviews = $db->delete(
"remove/deleteOlderThan",
new DateTime("-6 months")
);
// Individual type-safe fields can be pulled from queries that return only one column:
$userName = $db->fetchString("user/getUsernameById", 105);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.