我需要在我的应用程序中连接两个数据库。一个是MySQL DB,另一个是SQL Server DB。两者都托管在IIS中。与MySQL DB的连接没问题,但是当我尝试连接到SQL DB时,它显示了一些错误,如
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
);
而My_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文件中添加了扩展名。但我无法连接数据库