Esempio n. 1
0
<?php

require_once "autoload.php";
$factory = new ContactsDAO(MaBD::getInstance());
$lesContacts = $factory->getAll("ORDER by nom");
//echo json_encode($lesContacts, JSON_PRETTY_PRINT);
echo json_encode($lesContacts);
Esempio n. 2
0
require_once "autoload.php";
function afficheTout($contacts)
{
    echo "------- Tous les contacts :\n";
    foreach ($contacts->getAll() as $c) {
        echo $c, "\n";
    }
    echo "---------------------------\n";
}
$moi = new Contact(array('id' => DAO::UNKNOWN_ID, 'nom' => "Genthial", 'prénom' => "Damien", 'tél' => "04 75 99 99 99"));
echo $moi, "\n";
$contacts = new ContactsDAO(MaBD::getInstance());
echo $contacts->getOne(1), "\n";
echo $contacts->getOne(2), "\n";
echo "------- Tous les contacts :\n";
foreach ($contacts->getAll() as $c) {
    echo $c, "\n";
}
echo "---------------------------\n";
echo "Enregistrement de ";
$contacts->insert($moi);
echo $moi, "\n";
echo "------- Tous les contacts triés par nom :\n";
foreach ($contacts->getAll("ORDER BY nom") as $c) {
    echo $c, "\n";
}
echo "---------------------------\n";
echo "Modification de {$moi}\n";
$moi->tél = "04 75 41 88 12";
$moi->prénom = NULL;
$contacts->update($moi);
Esempio n. 3
0
<?php

require_once "autoload.php";
// ------- fonctions utilitaires -------
function toHTMLRow($contact, $idAModifier)
{
    echo '<tr>';
    echo sprintf('<td>%s</td><td>%s</td><td>%s</td>', $contact->nom, $contact->prénom, $contact->tél);
    echo "</tr>\n";
}
// ------- contrôleur -------
$contacts = new ContactsDAO(MaBD::getInstance());
// Chargement de la liste des contacts à afficher
$lesContacts = $contacts->getAll("ORDER BY nom,prénom ASC");
// ------- vue -------
echo '<?xml version="1.0" encoding="UTF-8"?>', "\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
   <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/>
   <link rel="stylesheet" type="text/css" href="Contacts.css"/>
   <title>Liste des contacts</title>
</head>
<body>
<p class="entete"><a href="gestion.php">Modifier</a></p> 
<h1>Liste des contacts</h1>
<table>
    <thead>
        <tr><th>Nom</th><th>Prénom</th><th>Téléphone</th></tr>
    </thead>