1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| class ami{
public $id_ami;
public $lastname;
public $firstname;
public $birthdate;
public function getname(){
return $this->lastname . ' '. $this->firstname;
}
}
try {
$db = Zend_Db::factory('Pdo_Mysql', $config->database);
$db->getConnection();
} catch (Zend_Db_Adapter_Exception $e) {
echo $e->getMessage();
} catch (Zend_Exception $e) {
echo $e->getMessage();
}
$sql = "SELECT * FROM ami";
$stmt = $db->query($sql);
$obj = $stmt->fetchAll(PDO::FETCH_CLASS,'ami');
foreach($obj as $ami)
{
echo $ami->getname().'<br />';
}
$dbh = null; |
Partager