Пример #1
0
 public function search()
 {
     $lang = Router::getLanguage();
     $dbc = Connect::getConnection();
     $indexModel = new IndexModel();
     $material_type_array = $indexModel->getType_of_Materials();
     $data_total = array();
     foreach ($material_type_array as $val) {
         $material_type = $val['type_name'];
         if ($material_type != 'Admin') {
             $fields = new FieldsModel($material_type);
             $fields_list = '';
             $fields_list_value = '';
             foreach ($fields->getFields() as $v) {
                 if ($v != 'id' && $v != 'alias' && $v != 'id_' . $material_type . '') {
                     $fields_list .= ',`' . $v . '` ';
                     $fields_list_value .= $v . " LIKE '%" . $this->search_request . "%' OR ";
                 }
             }
             $fields_list_value = trim($fields_list_value, 'OR ');
             $sql = "SELECT `id`, `id_{$material_type}` {$fields_list}, `alias` FROM `{$material_type}_{$lang}` WHERE {$fields_list_value}";
             $placeholders = array();
             $data = $dbc->getDate($sql, $placeholders);
             $data_total[$material_type] = $data;
         }
     }
     return $data_total;
 }
Пример #2
0
 public function getAliasDate()
 {
     $dbc = Connect::getConnection();
     $sql = "SELECT type_name FROM  type_of_materyals";
     $placeholders = array();
     $data = $dbc->getDate($sql, $placeholders);
     // Debugger::PrintR($data);
     $data_low_register = array();
     foreach ($data as $val) {
         $data_low_register[]['type_name'] = strtolower($val['type_name']);
     }
     //   Debugger::PrintR($data_low_register);
     foreach ($data_low_register as $v) {
         if ($v['type_name'] != 'admin') {
             $sql_arr[] = "SELECT  p.id, p.controller, p.action, {$v['type_name']}_en.alias AS alias_en, {$v['type_name']}_uk.alias AS alias_uk FROM\npages p JOIN `{$v['type_name']}` JOIN `{$v['type_name']}_en` JOIN `{$v['type_name']}_uk` ON (p.id = {$v['type_name']}.id_page AND {$v['type_name']}.id =\n{$v['type_name']}_en.id_{$v['type_name']}) AND (p.id = {$v['type_name']}.id_page AND {$v['type_name']}.id = {$v['type_name']}_uk.id_{$v['type_name']} )";
         } else {
             $sql_arr[] = "SELECT p.id, p.controller, p.action, {$v['type_name']}.alias AS alias_en, {$v['type_name']}.alias AS alias_uk FROM\npages p JOIN `{$v['type_name']}` ON p.id = {$v['type_name']}.id_page";
         }
     }
     $sql = implode(' UNION ALL ', $sql_arr);
     $placeholders = array();
     $data = $dbc->getDate($sql, $placeholders);
     $d = array();
     foreach ($data as $v) {
         $d[$v['id']] = $v;
         unset($d[$v['id']]['id']);
     }
     return $d;
 }
 public function saveToDb()
 {
     $placeholders = array('name' => $this->name, 'email' => $this->email, 'date' => $this->date, 'message' => $this->message);
     $sql = 'INSERT INTO  message (user_name, user_email, message_date, message) VALUES (:name,:email, :date, :message)';
     $dbc = Connect::getConnection();
     $sth = $dbc->getPDO()->prepare($sql);
     $sth->execute($placeholders);
 }
 public function getMaxId()
 {
     $placeholders = array();
     $dbc = Connect::getConnection();
     $sql = "SELECT MAX(id) AS max_id FROM `main_menu` ";
     $data = $dbc->getDate($sql, $placeholders);
     return $data[0]['max_id'];
 }
 public function deleteMessage($id)
 {
     $placeholders = array('id' => $id);
     $dbc = Connect::getConnection();
     $sql = "DELETE FROM `message` WHERE id = :id";
     $sth = $dbc->getPDO()->prepare($sql);
     $sth->execute($placeholders);
 }
 public function insertIntoDB()
 {
     $placeholders = array('username' => $this->username, 'email' => $this->email, 'password' => new Password($this->password));
     $sql = 'INSERT INTO  users (username, email, password) VALUES (:username,:email, :password)';
     $dbc = Connect::getConnection();
     $sth = $dbc->getPDO()->prepare($sql);
     $sth->execute($placeholders);
 }
Пример #7
0
 public function delete()
 {
     $this->delete_from_menu();
     $placeholders = array('id' => $this->id);
     $dbc = Connect::getConnection();
     $sql = "DELETE FROM `pages` WHERE id = :id";
     $sth = $dbc->getPDO()->prepare($sql);
     $sth->execute($placeholders);
 }
Пример #8
0
 public function getMenuDatePage($id_page)
 {
     $lang = Router::getLanguage();
     $dbc = Connect::getConnection();
     $placeholders = array('id_page' => $id_page);
     $sql = "SELECT mm.id as id_menu_item, mm.id_parent_page, mm_{$lang}.name AS name_menu_item, mm_{$lang}.alias_menu, mm.status\n         FROM main_menu mm JOIN main_menu_{$lang} mm_{$lang} ON mm.id_page = :id_page AND mm.id = mm_{$lang}.id_main_menu";
     $date = $dbc->getDate($sql, $placeholders);
     return $date;
 }
Пример #9
0
 public function getBooksCount()
 {
     $dbc = Connect::getConnection();
     $sql = 'SELECT count(*) AS itemsCount FROM books';
     $placeholders = array();
     $count_array = $dbc->getDate($sql, $placeholders);
     $count = $count_array[0]['itemsCount'];
     return $count;
 }
Пример #10
0
 public function getUser()
 {
     $dbc = Connect::getConnection();
     $sql = "SELECT * FROM users WHERE username = :username AND password = :password";
     $placeholders = array('username' => $this->username, 'password' => new Password($this->password));
     $date = $dbc->getDate($sql, $placeholders);
     if (!$date) {
         return false;
     }
     return $date;
     //!empty($date);
 }
Пример #11
0
 public function updateStaticTranslation(Request $request)
 {
     $dbc = Connect::getConnection();
     $text_en = str_replace("'", " ", $request->post('text_en'));
     $text_uk = str_replace("'", " ", $request->post('text_uk'));
     $text_en = $request->post('text_en');
     $text_uk = $request->post('text_uk');
     $placeholders = array('key' => $request->post('key'), 'text_en' => $text_en, 'text_uk' => $text_uk);
     Debugger::PrintR($placeholders);
     $sql = "UPDATE `static_translation` SET `text_en`= :text_en,`text_uk`= :text_uk WHERE `key`= :key";
     $sth = $dbc->getPDO()->prepare($sql);
     $sth->execute($placeholders);
 }
Пример #12
0
 private function takeFields($material_type)
 {
     $lang = Config::get('default_language');
     $dbc = Connect::getConnection();
     $sql = "SELECT COLUMN_NAME\nFROM INFORMATION_SCHEMA.COLUMNS\nWHERE table_name = '" . $material_type . "_" . $lang . "'";
     $placeholders = array();
     $d = $dbc->getDate($sql, $placeholders);
     $data = array();
     foreach ($d as $v) {
         $data[] = $v['COLUMN_NAME'];
     }
     $data = array_unique($data);
     return $data;
 }
Пример #13
0
 public function update()
 {
     $dbc = Connect::getConnection();
     $placeholders = array();
     $sql = "DELETE FROM `pages_in_block`";
     $sth = $dbc->getPDO()->prepare($sql);
     $sth->execute($placeholders);
     $this->id_array = array_diff_key($this->id_array, $this->delete_array);
     // Debugger::PrintR($this->id_array);
     if (!empty($this->id_array)) {
         $values = '';
         foreach ($this->id_array as $v) {
             if ($v) {
                 $values .= ',(' . $v . ',' . $v . ')';
             }
         }
         $values = substr($values, 1);
         $sql = "INSERT INTO `pages_in_block`(`id`, `id_page`) VALUES {$values}";
         //  echo $sql;
         $sth = $dbc->getPDO()->prepare($sql);
         $sth->execute($placeholders);
     }
 }
Пример #14
0
 public function getBasicPageBlock()
 {
     $dbc = Connect::getConnection();
     $placeholders = array();
     $sql = "SELECT `id_page` FROM `pages_in_block`";
     $d = $dbc->getDate($sql, $placeholders);
     $data = array();
     if (!empty($d)) {
         $id_pages = '';
         foreach ($d as $v) {
             $id_pages .= ',' . $v['id_page'];
         }
         $id_pages = substr($id_pages, 1);
         $placeholders = array();
         $lang = Router::getLanguage();
         $sql = "SELECT bp_{$lang}.title, bp_{$lang}.alias, bp.id_page FROM basic_page_{$lang} bp_{$lang} JOIN basic_page bp ON bp_{$lang}.id_basic_page = bp.id AND bp.id_page IN({$id_pages})";
         $data = $dbc->getDate($sql, $placeholders);
     }
     return $data;
 }
Пример #15
0
 private function edit_menu($id_page, $lang, $new_alias, $title = null, $id_parent = null)
 {
     $placeholders = array('id' => $id_page);
     $dbc = Connect::getConnection();
     $sql = "SELECT id_page FROM `main_menu` WHERE id_parent_page = :id";
     $data = $dbc->getDate($sql, $placeholders);
     // Debugger::PrintR($date);
     $new_title = $title ? $title : $this->title_or_menu_name;
     $id_p = $id_parent ? $id_parent : $this->id_parent;
     //   $lang = Router::getLanguage();
     $placeholders = array('id' => $id_page, 'title' => $new_title, 'alias' => $new_alias, 'id_parent_page' => $id_p);
     $sql = "UPDATE main_menu_{$lang} mm_{$lang} JOIN main_menu mm SET mm_{$lang}.name = :title, mm_{$lang}.alias_menu = :alias, mm.id_parent_page = :id_parent_page\n         WHERE mm_{$lang}.id_main_menu = mm.id AND mm.id_page = :id";
     $sth = $dbc->getPDO()->prepare($sql);
     $sth->execute($placeholders);
     $placeholders = array();
     $this->recurs_update_menu($dbc, $data, $placeholders, $lang);
 }