<?

require_once("classes/User.class.php");
require_once(
"header.php");

    
/**
     * We use the "query by example" or QBE technique to retrieve the user by its email.    
     * We create an example object, populating its fields with the values we want matched, 
     * and sending the example object to the phpersistence query system.
     * phpersistence will return the object that look like the example.
     */     
    
$example = new User();
    
$example->mail "michael@phpersistence.org";

  
// lets phpersistence do the job...
    
$persistence = new Persistence();
    
    
/**
     * findOneByExample returns one single element found by example.
     * If the resultset is composed of more (or less) than 1 result, false is returned.
     * 
     * If you want to get more than one result use findByExample (see next example)     
     */
    
$user $persistence->findOneByExample($example) or die("phpersistence found more or less than 1 user");

    
// done
    // Logger::debug prints a dump of the object
    
Logger::debug($user);
    
?>