diff options
| author | polo <ordipolo@gmx.fr> | 2022-12-19 02:51:03 +0100 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2022-12-19 02:51:03 +0100 |
| commit | dedbe2f5cee33431c1299c7f0dbef4e247dc2447 (patch) | |
| tree | 4d2481ca044aae30886a9879acd53c4777c180bc /src/model/traits.php | |
| parent | ff14091476a35de16a9ea3208501040cfae93a06 (diff) | |
| download | AppliGestionPHP-dedbe2f5cee33431c1299c7f0dbef4e247dc2447.tar.gz AppliGestionPHP-dedbe2f5cee33431c1299c7f0dbef4e247dc2447.tar.bz2 AppliGestionPHP-dedbe2f5cee33431c1299c7f0dbef4e247dc2447.zip | |
nouveau client main.php en cours
Diffstat (limited to 'src/model/traits.php')
| -rw-r--r-- | src/model/traits.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/model/traits.php b/src/model/traits.php new file mode 100644 index 0000000..43d9b7f --- /dev/null +++ b/src/model/traits.php | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | <?php | ||
| 2 | // model/traits.php | ||
| 3 | |||
| 4 | trait ModelChildren // pour ne pas toucher au constructeur de la classe Model | ||
| 5 | { | ||
| 6 | public function __construct() | ||
| 7 | { | ||
| 8 | $this->table = strtolower(__CLASS__); | ||
| 9 | } | ||
| 10 | |||
| 11 | public function setIdFromLastInsertID() // à faire juste après l'écriture d'une nouvelle entrée | ||
| 12 | { | ||
| 13 | $this->db = parent::getInstance(); | ||
| 14 | $this->ID = $this->db->lastInsertId(); // méthode de PDO | ||
| 15 | } | ||
| 16 | } | ||
