public function QuestionsAction() { $word = Tools::getValue('w', ''); $cat = Tools::getValue('c', ''); $answ = Tools::getValue('a', ''); $quest = new Consult($this->context); if (!empty($cat)) { if (!empty($word)) { $AddWhere = 'cid = "' . $cat . '" AND (title LIKE "%' . $word . '%" OR body LIKE "%' . $word . '%")'; $search = $quest->getSearch($AddWhere); $total = array_column($search, 'isAnswer'); $total = array_count_values($total); } else { $AddWhere = 'cid = "' . $cat . '"'; $search = $quest->getSearch($AddWhere); $total = array_column($search, 'isAnswer'); $total = array_count_values($total); } } else { $AddWhere = '(title LIKE "%' . $word . '%" OR body LIKE "%' . $word . '%")'; $search = $quest->getSearch($AddWhere); $total = array_column($search, 'isAnswer'); $total = array_count_values($total); } $post = $quest->getPOST(); $questions = $this->db->query('select id, title, body, answer from consult_questions where isActive = 1 ORDER BY id DESC ')->fetchall(); $category = $this->db->query('select id, name, alt_name, small_img from consult_category')->fetchall(); $expert = $this->db->query(' SELECT cc.id, cc.name, cc.alt_name, ud.FirstName, ud.LastName, ud.UserID FROM UserData as ud, consult_category as cc, consult_user_category as cu WHERE ud.UserID=cu.uid and cc.id=cu.cid ')->fetchall(); $this->view->breadcrumbs = array(array('url' => '/', 'title' => 'Главная'), array('url' => '/consult/', 'title' => 'Консультации'), array('url' => '../consult/questions', 'title' => 'Вопросы')); $this->view->setVars(array('category' => $category, 'expert' => $expert, 'questions' => $questions, 'search' => $search, 'total' => $total)); $this->view->generate(); }