1. Go to this page and download the library: Download andyfleming/handy 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/ */
andyfleming / handy example snippets
class Person extends HandyModel {
const TABLE_NAME = 'people';
}
$person = Person::lookupByID(12);
// Returns single Person object or false
if (!$person) {
echo "Person 12 was not found!";
} else {
echo "Person 12's first name is ".$person->get('first_name');
}
$person = Person::lookup("`first_name`='Bob'");
// Returns single Person object or false
$people = Person::lookupEach("age > 30");
// Returns array of Person objects by ID or empty array
if (count($people) == 0) {
echo 'No one found!';
} else {
foreach ($people as $person) {
echo $person->get('first_name').": ".$person->get('age');
echo "<br />";
}
}
/*
Array people
17 => Object Person
27 => Object Person
28 => Object Person
*/
$person = Person::lookupRandom("`age` > 30");
// Returns single (random) Person object or false
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.