示例#1
0
 public function findByID($params)
 {
     $id_c = isset($params->id_c) ? $params->id_c : "";
     try {
         $st = $this->db->prepare("SELECT building.adress, company.name\n\t\t\t\tFROM  building\n\t\t\t\tINNER JOIN  company ON (building.id_b = company.id_b) where company.id_c=:id_c");
         $st->bindParam(':id_c', $id_c, PDO::PARAM_INT);
         $result_exec = $st->execute();
         $result = $this->createDefaultResponse($st);
     } catch (PDOException $e) {
         $result = $this->createJsonError();
     }
     //Список телефонов
     $phones = new phone($this->db);
     $phones_list = $phones->getList($params);
     if ($phones_list !== false) {
         $result->items[0]->phones = $phones_list;
     }
     //Path Breadcrumbs
     $catalog = new catalog($this->db);
     $path_breadcrumbs = "";
     try {
         $st = $this->db->prepare("SELECT id_ca\n\t\t\t\tFROM catalog_company INNER JOIN company\n\t\t\t\tON (company.id_c = catalog_company.id_c) where company.id_c=:id_c");
         $st->bindParam(':id_c', $id_c, PDO::PARAM_INT);
         $result_exec = $st->execute();
         $st->setFetchMode(PDO::FETCH_OBJ);
         while ($item = $st->fetch()) {
             $path = $catalog->getBreadcrumbs($item);
             if ($path !== false) {
                 $path_breadcrumbs .= $path;
             }
         }
         $result->items[0]->path = $path_breadcrumbs;
     } catch (PDOException $e) {
         $result = $this->createJsonError();
     }
     return $result;
 }