it_employee.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. class ITEmployeeComtroller extends DBProvider
  3. {
  4. private $_connect_db;
  5. function __construct()
  6. {
  7. $this->_connect_db = parent::connect();
  8. }
  9. // public function get_all()
  10. // {
  11. // $query = "SELECT * FROM it_employee;";
  12. // $stmt = $this->_connect_db->prepare($query);
  13. // $stmt->execute();
  14. // return $stmt->fetchAll(PDO::FETCH_CLASS, "ITDeportament");
  15. // }
  16. public function get_employee_by_deportament($id_deportament)
  17. {
  18. $query = "SELECT
  19. ie.id,
  20. ie.fio,
  21. ip.name as `position`,
  22. ie.phone
  23. from it_employee ie
  24. inner join it_position ip on ip.id = ie.id_position
  25. WHERE ie.id_deportament =:id_deportament ORDER BY ip.id;";
  26. $stmt = $this->_connect_db->prepare($query);
  27. $stmt->bindParam("id_deportament", $id_deportament, PDO::PARAM_INT);
  28. $stmt->execute();
  29. return $stmt->fetchAll(PDO::FETCH_CLASS, "ITEmployeeToDeportament");
  30. }
  31. }
  32. class ITEmployeeToDeportament
  33. {
  34. public $id, $fio, $position, $phone;
  35. }