Skip to content

Instantly share code, notes, and snippets.

@rohman
Created April 17, 2013 23:21
Show Gist options
  • Save rohman/5408574 to your computer and use it in GitHub Desktop.
Save rohman/5408574 to your computer and use it in GitHub Desktop.
CodeIgniter ODBC Connection
<?php
$active_group = 'default';
$active_record = FALSE;
$db['default']['hostname'] = 'Driver={SQL Server};Server=127.0.0.1;Database=databasenya; Uid=sa;Pwd=sa;';
$db['default']['username'] = 'sa';
$db['default']['password'] = 'sa';
$db['default']['database'] = 'databasenya';
$db['default']['dbdriver'] = 'odbc';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
?>
@imran300
Copy link

imran300 commented May 1, 2017

Hello Sir,
I need your help. I am doing connectivity with MS Access DB. Here is my code

$db['forum']['hostname'] = "Driver={Microsoft Access Driver (.mdb,.accdb)};DBQ=E:\Att2003.mdb";
$db['forum']['username'] = "";
$db['forum']['password'] = "";
$db['forum']['database'] = "Driver={Microsoft Access Driver (.mdb,.accdb)};DBQ=E:\Att2003.mdb";
$db['forum']['dbdriver'] = "odbc";
$db['forum']['dbprefix'] = "";
$db['forum']['pconnect'] = FALSE;
$db['forum']['db_debug'] = TRUE;
$db['forum']['cache_on'] = FALSE;
$db['forum']['cachedir'] = "";
$db['forum']['char_set'] = "utf8";
$db['forum']['dbcollat'] = "utf8_general_ci";
$db['forum']['swap_pre'] = '';
$db['forum']['autoinit'] = TRUE;
$db['forum']['stricton'] = FALSE;

I say Unable to connect to database using the provided settings
and also says no such host is known

@wcoarite
Copy link

imran300 did you make the connection? I have the same problem

@BrunoPastorello
Copy link

Oi tudo bem, não sei se tem a ver, estou conectando no sql server igual esta string no codeigniter, mas os registros com caracteres especias esta dando "?" sabe me ajudar?

Cara, sei que faz muito tempo, mas você conseguiu resolver isso?

@dianadipratama1
Copy link

@rohman how with codeigniter with MySQL ODBC 5.1 Driver ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment