当前位置: 首页>>代码示例>>PHP>>正文


PHP Connect::getConnection方法代码示例

本文整理汇总了PHP中Connect::getConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP Connect::getConnection方法的具体用法?PHP Connect::getConnection怎么用?PHP Connect::getConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Connect的用法示例。


在下文中一共展示了Connect::getConnection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: search

 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;
 }
开发者ID:artemkuchma,项目名称:php_academy_site2,代码行数:28,代码来源:SearchModel.php

示例2: getAliasDate

 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;
 }
开发者ID:artemkuchma,项目名称:php_academy_site2,代码行数:29,代码来源:AliasModel.php

示例3: saveToDb

 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);
 }
开发者ID:artemkuchma,项目名称:PHP_academy_site1,代码行数:8,代码来源:ContactModel.php

示例4: getMaxId

 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'];
 }
开发者ID:artemkuchma,项目名称:php_academy_site2,代码行数:8,代码来源:MenuIdEditModel.php

示例5: deleteMessage

 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);
 }
开发者ID:artemkuchma,项目名称:php_academy_site2,代码行数:8,代码来源:ContactModel.php

示例6: insertIntoDB

 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);
 }
开发者ID:artemkuchma,项目名称:php_academy_site2,代码行数:8,代码来源:RegisterModel.php

示例7: delete

 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);
 }
开发者ID:artemkuchma,项目名称:php_academy_site2,代码行数:9,代码来源:deleteModel.php

示例8: getMenuDatePage

 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;
 }
开发者ID:artemkuchma,项目名称:php_academy_site2,代码行数:9,代码来源:MenuModel.php

示例9: getBooksCount

 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;
 }
开发者ID:artemkuchma,项目名称:PHP_academy_site1,代码行数:9,代码来源:BookModel.php

示例10: getUser

 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);
 }
开发者ID:artemkuchma,项目名称:php_academy_site2,代码行数:12,代码来源:LoginModel.php

示例11: updateStaticTranslation

 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);
 }
开发者ID:artemkuchma,项目名称:php_academy_site2,代码行数:13,代码来源:AdminModel.php

示例12: takeFields

 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;
 }
开发者ID:artemkuchma,项目名称:php_academy_site2,代码行数:14,代码来源:FieldsModel.php

示例13: update

 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);
     }
 }
开发者ID:artemkuchma,项目名称:php_academy_site2,代码行数:23,代码来源:BlockModel.php

示例14: getBasicPageBlock

 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;
 }
开发者ID:artemkuchma,项目名称:php_academy_site2,代码行数:20,代码来源:IndexModel.php

示例15: edit_menu

 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);
 }
开发者ID:artemkuchma,项目名称:php_academy_site2,代码行数:17,代码来源:AddEditModel.php


注:本文中的Connect::getConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。