Skip to content

Instantly share code, notes, and snippets.

@mikesimons
Created September 15, 2010 10:15
Show Gist options
  • Save mikesimons/580513 to your computer and use it in GitHub Desktop.
Save mikesimons/580513 to your computer and use it in GitHub Desktop.
<?php
$people = new People;
$young = $people->select()->young();
$youngMale = $young->male();
$youngFemale = $young->female();
$maleWithDocuments = $people->select()->male()->withDocuments();
$publishedBetween2001And2005 = $maleWithDocuments->publishedBetween('2001-01-01 00:00:00', '2005-12-31 23:59:59');
show($people, $youngMale);
show($people, $youngFemale);
show($people, $maleWithDocuments);
show($people, $publishedBetween2001And2005);
function show($table, $select) {
echo "QUERY: $select\n";
echo "RESULTS: \n";
foreach($table->fetchAll($select) as $person) {
echo "Name: {$person->firstname} {$person->lastname}\n";
echo "Age: {$person->age}\n";
echo "Sex: {$person->sex}\n";
echo "-------\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment