it_deportament.php 774 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. class ITDeportamentComtroller extends DBProvider {
  3. private $_connect_db;
  4. function __construct()
  5. {
  6. $this->_connect_db = parent::connect();
  7. }
  8. public function get_all(){
  9. $query = "SELECT * FROM it_deportament;";
  10. $stmt = $this->_connect_db->prepare($query);
  11. $stmt->execute();
  12. return $stmt->fetchAll(PDO::FETCH_CLASS, "ITDeportament");
  13. }
  14. public function get_all_by_id(int $id){
  15. $query = "SELECT * FROM it_deportament WHERE id = :id;";
  16. $stmt = $this->_connect_db->prepare($query);
  17. $stmt->bindValue("id", $id, PDO::PARAM_INT);
  18. $stmt->execute();
  19. return $stmt->fetchAll(PDO::FETCH_CLASS, "ITDeportament")[0];
  20. }
  21. }
  22. class ITDeportament {
  23. public $id, $name;
  24. }