123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- class ITEmployeeComtroller extends DBProvider
- {
- private $_connect_db;
- function __construct()
- {
- $this->_connect_db = parent::connect();
- }
- // public function get_all()
- // {
- // $query = "SELECT * FROM it_employee;";
- // $stmt = $this->_connect_db->prepare($query);
- // $stmt->execute();
- // return $stmt->fetchAll(PDO::FETCH_CLASS, "ITDeportament");
- // }
- public function get_employee_by_deportament($id_deportament)
- {
- $query = "SELECT
- ie.id,
- ie.fio,
- ip.name as `position`,
- ie.phone
- from it_employee ie
- inner join it_position ip on ip.id = ie.id_position
- WHERE ie.id_deportament =:id_deportament ORDER BY ip.id;";
- $stmt = $this->_connect_db->prepare($query);
- $stmt->bindParam("id_deportament", $id_deportament, PDO::PARAM_INT);
- $stmt->execute();
- return $stmt->fetchAll(PDO::FETCH_CLASS, "ITEmployeeToDeportament");
- }
- }
- class ITEmployeeToDeportament
- {
- public $id, $fio, $position, $phone;
- }
|