本文整理汇总了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
//.........这里部分代码省略.........