connectsql数据库

8iwquhpp  于 2021-06-21  发布在  Mysql
关注(0)|答案(0)|浏览(124)

我需要在我的应用程序中连接两个数据库。一个是mysql数据库,另一个是sqlserver数据库。都在iis中托管。到mysql数据库的连接是正常的,但是当我尝试连接到sqldb时,它会显示一些错误,比如 Call to undefined function sqlsrv_connect() 下面是我的database.php文件

$active_group = 'default';
$db['default'] = array(
'dsn'   => '',
'hostname' => 'xxxxx',
'username' => 'xxxxx',
'password' => 'xxxxx',
'database' => 'mydb',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);

$db['voiceengine'] = array(
'dsn'   => '',
'hostname' => 'xxxxx',
'username' => 'xxxxx',
'password' => 'xxxxx',
'database' => 'db1',
'dbdriver' => 'sqlsrv',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => FALSE,
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);

而我的\u model.php是

function checkFile($file) {
    $this->db->where('FileName', $file);
    return $this->db->count_all_results('voicefile_tbl');
}

function scheduleVoiceSMS($data) { 
    $voiceengine = $this->load->database('voiceengine', TRUE);
    $scheduleData = array();

    $this->db->select('Name, Duration');
    $this->db->where('FileName', $data['file']);
    $result = $this->db->get('voicefile_tbl')->row_array();

    if(isset($data['sch_time']) && $data['sch_time'] != ""){
        $campaignData = array(  
            'vaCampaignName' => $result['Name'],
            'vaFileName' => $data['file'],
            'intFileDurationInSeconds' => $result['Duration'],
            'dtScheduledDateTime' => date('Y-m-d H:i:s', strtotime($data['sch_time'])),
            'intUserID' => $data['UserID']
        );
    }

    $voiceengine->insert('Campaign', $campaignData);
    $id = $this->db->insert_id();

    $mobiles = explode(',', $data['destinations']);

    foreach($mobiles as $mobile){            

        if (strlen($mobile) == 12 && substr($mobile, 0, 2) == "91")
            $mobile = substr($mobile, 2, 10);

        $campaignData = array(
            'intCampaignID' => $id,
            'intMobileNumber' => $mobile);                    

        array_push($scheduleData, $campaignData);
    }
    $voiceengine->insert_batch('CampaignNumbers', $scheduleData);

}

我已经安装了dll文件,并且在php.ini文件中添加了扩展名。但我无法连接到数据库

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题