Skip to content
Snippets Groups Projects
Commit 9668aa79 authored by NF17 Etudiant's avatar NF17 Etudiant
Browse files

Merge branch 'master' of gitlab.utc.fr:nf17-camp-p14/clivi

parents ab62c71c da4ef8f2
No related branches found
No related tags found
No related merge requests found
......@@ -6,10 +6,10 @@ class ListView
protected $objArray;
public $class;
public function __construct($class, $title)
public function __construct($class, $title, $id=null)
{
$this->title = $title;
$this->objArray = $class::getAll();
$this->objArray = $class::getAll($id);
$this->class = $class;
}
......
......@@ -23,15 +23,19 @@ class Objet
return $dbName;
}
public static function getAll()
public static function getAll($id = null)
{
$className = get_called_class();
$dbName = self::dbName();
$bdd = new Db();
$result = Array();
$requete_prepare = $bdd->db->prepare("SELECT * FROM ".$dbName); // on prépare notre requête
$requete_prepare->execute();
if($id == null) {
$requete_prepare = $bdd->db->prepare("SELECT * FROM ".$dbName); // on prépare notre requête
$requete_prepare->execute();
} else {
$requete_prepare = $bdd->db->prepare("SELECT * FROM ".$dbName." WHERE ".$this->_primaryAttr." = :id");
$requete_prepare->execute(array("id" => $id));
}
while($ligne = $requete_prepare->fetch(PDO::FETCH_ASSOC)) {
$temp = new $className();
......@@ -155,7 +159,7 @@ class Objet
return self::dbName()." #".$this->{$this->_primaryAttr};
}
public function getList($title) {
return new ListView(get_called_class(), $title);
public function getList($title, $id=null) {
return new ListView(get_called_class(), $title, $id);
}
}
\ No newline at end of file
......@@ -27,6 +27,9 @@ switch($action) {
$facture->select($_GET['id']);
$formConf = $facture->getForm();
include 'view/formDetail.php';
$list = LigneFacture::getList("Détail de la facture", $_GET["id"]);
include 'view/list.php';
break;
default:
include 'view/404.php';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment