连接访问codeigniter然后导出到mysql

时间:2016-03-14 20:10:16

标签: php codeigniter-2

此代码有什么问题,继续使用提供的设置无法连接到数据库服务器。"尝试连接访问数据库时

public function update_dbx(){
    $loc='Driver={Microsoft Access Driver (*.mdb)};DBQ='.base_url('database\simardi.mdb');
  $confd['hostname'] = $loc;
  $confd['username'] = '';
  $confd['password'] = '';
  $confd['database'] = $loc;
  $confd['dbdriver'] = 'odbc';
  $confd['dbprefix'] = '';
  $confd['pconnect'] = TRUE;
  $confd['db_debug'] = TRUE;
  $confd['cache_on'] = FALSE;
  $confd['cachedir'] = '';
  $confd['char_set'] = 'utf8';
  $confd['dbcollat'] = 'utf8_general_ci';
  $confd['swap_pre'] = '';
  $confd['autoinit'] = TRUE;
  $confd['stricton'] = FALSE;

    $CI = &get_instance();
    $this->db2 = $CI->load->database('db2', $confd);
    $qryx = $this->db2->query("SELECT * FROM INAKTIFMASTER");
    foreach($qryx->result() as $data){
        $this->db->insert('INAKTIFMASTER',$data);
        //print_r($data);
    }

我试图通过上传从accces导出mysql数据库

我有默认和" db2"我的database.php中的数据库配置

修改

  $db['db2']['hostname'] = 'Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\xampp\htdocs\site\database\data.mdb';
   $db['db2']['username'] = '';
   $db['db2']['password'] = '';
   $db['db2']['database'] = 'Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\xampp\htdocs\site\database\data.mdb';

$ db [' db2'] [' dbdriver'] =' odbc';

我需要使用base_url

1 个答案:

答案 0 :(得分:0)

首先,您使用base_url()。这不等于;

C:\xampp\htdocs\site\

要在目录上访问,您可以使用

__DIR__."database/data.mdb"

在执行使用var_dump(__DIR__);之前,检查你得到了什么。