0

I need to connect two databases in my application. One is MySQL DB and the other one is SQL Server DB. Both hosted in IIS. The connection to MySQL DB is ok, but when I try to connect to SQL DB it shows some error like
Call to undefined function sqlsrv_connect()

The following is my database.php file

$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
);

And My_model.php is

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);

}

I have installed the dll file, and the extension added in php.ini file. But I cannot connect to the database

geeth
  • 704
  • 2
  • 14
  • 42
  • 2
    Possible of duplicate : https://stackoverflow.com/questions/33313823/call-to-undefined-function-sqlsrv-connect-in-xampp – Virb Apr 23 '18 at 04:27
  • 2
    looks like the The SQLSRV extension is not installed –  Apr 23 '18 at 04:30
  • resolved the issue. the issue is actually the extension was disabled in the server. – geeth Apr 23 '18 at 05:00

0 Answers0