diff options
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 | } | ||
