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


PHP JO_Db::setAdapterConfig方法代码示例

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


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

示例1: indexAction

 public function indexAction()
 {
     $request = $this->getRequest();
     $update_for = 'themes';
     $db = JO_Db::getDefaultAdapter();
     $this->view->msg_error = array();
     $this->view->msg_success = array();
     //begin updater
     $old_sys_config = BASE_PATH . '/old_sys/data/uploads/language/config.php';
     if (!file_exists($old_sys_config)) {
         $this->view->msg_error['old_sys'] = 'Please move the "data" folder of your old system into folder: <strong>' . BASE_PATH . '/old_sys/</strong>';
     }
     if (!$this->view->msg_error && $request->isPost()) {
         self::unlink(BASE_PATH . '/uploads/items/', true);
         self::unlink(BASE_PATH . '/uploads/attributes/', true);
         self::unlink(BASE_PATH . '/uploads/cache/', true);
         self::unlink(BASE_PATH . '/uploads/countries/', true);
         $db_queries = array();
         include_once $old_sys_config;
         $old_config = $db->getConfig();
         $db_config = $old_config;
         $db_config['host'] = $configArr['mysql_host'];
         $db_config['username'] = $configArr['mysql_user'];
         $db_config['password'] = $configArr['mysql_pass'];
         $db_config['dbname'] = $configArr['mysql_db'];
         $old_db_tables = $db->listTables();
         $new_db = JO_Db::setAdapterConfig($db_config);
         $new_db_tables = $new_db->listTables();
         // other tables
         $all_arr = array('bulletin', 'bulletin_emails', 'collections', 'collections_rates', 'contacts', 'contacts_categories', 'deposit', 'history', 'percents', 'quiz', 'quiz_answers', 'users_emails', 'users_followers', 'users_referals_count', 'users_status', 'user_groups', 'withdraw', 'items_attributes', 'items_collections', 'items_comments', 'items_faqs', 'items_rates', 'items_tags', 'items_to_category');
         foreach ($all_arr as $table) {
             if (!in_array($table, $old_db_tables) || !in_array($table, $new_db_tables)) {
                 continue;
             }
             $query = $new_db->select()->from($table);
             $attributes_categories = $new_db->fetchAll($query);
             if ($attributes_categories) {
                 $db_queries['TRUNCATE'][] = array('table' => $table, 'where' => null);
                 foreach ($attributes_categories as $key => $val) {
                     $vals = array();
                     foreach ($val as $k => $d) {
                         if (self::is_serialized($d)) {
                             $vals[$k] = $d;
                         } else {
                             $vals[$k] = htmlspecialchars($d, ENT_QUOTES, 'utf-8');
                         }
                     }
                     if (count($vals) > 0) {
                         $db_queries[$table][] = $vals;
                     }
                 }
             }
         }
         //attributes_categories
         $attributes_categories = $new_db->fetchAll("SELECT * FROM `attributes_categories`");
         if ($attributes_categories) {
             $db_queries['TRUNCATE'][] = array('table' => 'attributes_categories', 'where' => null);
             foreach ($attributes_categories as $data) {
                 //					$db_queries[] = "INSERT INTO `attributes_categories` (`id`, `name`, `type`, `categories`, `visible`, `order_index`,`required`) VALUES ('".(int)$data['id'] ."', '".htmlspecialchars($data['name'], ENT_QUOTES, 'utf-8') ."', '".htmlspecialchars($data['type'], ENT_QUOTES, 'utf-8') ."', '".htmlspecialchars($data['categories'], ENT_QUOTES, 'utf-8') ."', '".htmlspecialchars($data['visible'], ENT_QUOTES, 'utf-8') ."', '".(int)$data['order_index'] ."',1);";
                 $db_queries['attributes_categories'][] = array('id' => (int) $data['id'], 'name' => htmlspecialchars($data['name'], ENT_QUOTES, 'utf-8'), 'type' => htmlspecialchars($data['type'], ENT_QUOTES, 'utf-8'), 'categories' => htmlspecialchars($data['categories'], ENT_QUOTES, 'utf-8'), 'visible' => 'true', 'order_index' => (int) $data['order_index'], 'required' => 1);
             }
         }
         //attributes
         $attributes_categories = $new_db->fetchAll("SELECT * FROM `attributes`");
         if ($attributes_categories) {
             $db_queries['TRUNCATE'][] = array('table' => 'attributes', 'where' => null);
             foreach ($attributes_categories as $data) {
                 $photo = self::copyFile(BASE_PATH . '/old_sys/data/uploads/attributes/' . $data['photo'], '/attributes/' . $data['photo']);
                 $db_queries['attributes'][] = array('id' => (int) $data['id'], 'category_id' => (int) $data['category_id'], 'name' => htmlspecialchars($data['name'], ENT_QUOTES, 'utf-8'), 'photo' => basename($photo), 'visible' => 'true', 'order_index' => (int) $data['order_index']);
             }
         }
         //attributes
         $attributes_categories = $new_db->fetchAll("SELECT * FROM `badges`");
         if ($attributes_categories) {
             $db_queries['TRUNCATE'][] = array('table' => 'badges', 'where' => null);
             foreach ($attributes_categories as $data) {
                 $photo = self::copyFile(BASE_PATH . '/old_sys/data/uploads/badges/' . $data['photo'], '/badges/' . $data['photo']);
                 $db_queries['badges'][] = array('id' => (int) $data['id'], 'name' => htmlspecialchars($data['name'], ENT_QUOTES, 'utf-8'), 'photo' => basename($photo), 'visible' => htmlspecialchars($data['visible'], ENT_QUOTES, 'utf-8'), 'from' => htmlspecialchars($data['from'], ENT_QUOTES, 'utf-8'), 'to' => htmlspecialchars($data['to']), 'type' => htmlspecialchars($data['type'], ENT_QUOTES, 'utf-8'), 'sys_key' => htmlspecialchars($data['sys_key'], ENT_QUOTES, 'utf-8'));
             }
         }
         //categories
         $attributes_categories = $new_db->fetchAll("SELECT * FROM `categories`");
         if ($attributes_categories) {
             $db_queries['TRUNCATE'][] = array('table' => 'categories', 'where' => null);
             $db_queries['TRUNCATE'][] = array('table' => 'categories_description', 'where' => null);
             foreach ($attributes_categories as $data) {
                 $db_queries['categories'][] = array('id' => (int) $data['id'], 'sub_of' => (int) $data['sub_of'], 'meta_title' => htmlspecialchars($data['meta_title'], ENT_QUOTES, 'utf-8'), 'meta_keywords' => htmlspecialchars($data['meta_keywords'], ENT_QUOTES, 'utf-8'), 'meta_description' => htmlspecialchars($data['meta_description'], ENT_QUOTES, 'utf-8'), 'visible' => htmlspecialchars($data['visible'], ENT_QUOTES, 'utf-8'), 'order_index' => (int) $data['order_index'], 'module' => $update_for);
                 $db_queries['categories_description'][] = array('id' => (int) $data['id'], 'lid' => 1, 'name' => htmlspecialchars($data['name'], ENT_QUOTES, 'utf-8'));
             }
         }
         //countries
         $attributes_categories = $new_db->fetchAll("SELECT * FROM `countries`");
         if ($attributes_categories) {
             $db_queries['TRUNCATE'][] = array('table' => 'countries', 'where' => null);
             foreach ($attributes_categories as $data) {
                 $photo = self::copyFile(BASE_PATH . '/old_sys/data/uploads/countries/' . $data['photo'], '/countries/' . $data['photo']);
                 $db_queries['countries'][] = array('id' => (int) $data['id'], 'name' => htmlspecialchars($data['name'], ENT_QUOTES, 'utf-8'), 'photo' => basename($photo), 'visible' => htmlspecialchars($data['visible'], ENT_QUOTES, 'utf-8'), 'order_index' => (int) $data['order_index']);
             }
         }
         //items
//.........这里部分代码省略.........
开发者ID:noikiy,项目名称:PD,代码行数:101,代码来源:IndexController.php


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