I’m recently began to use php again (last time was like 7 years ago) and some fiends recommended me to use codeigniter Framework.
i trying to connect to database server in MSSQL 2008 R2 using a the odbc driver, using x64 php version over x64 IIS. This is one of the reasons because i’m not using the php native driver provided by microsoft, the other one is because the production enviroment will be in CentOS, and btw doesn’t have any sense to use that driver ….
going to the point: Trying to connect to a database using active record / odbc configuration throws me this error
A Database Error Occurred
--------------------------
Error Number: 01000
[Microsoft][SQL Server Native Client 10.0][SQL Server]Executing SQL directly; no cursor.
SELECT * FROM (WebUsers)
Filename: C:\projects\php\test\system\database\DB_driver.php
Line Number: 330
and i’m only execute a simple query to retrieve a table.
$query = $this->db->get('WebUsers');
return $query->result_array();
these are my connection settings:
$db['default']['hostname'] = 'Driver={SQL Server Native Client 10.0};Server=localhost;Database=XXXXXXXXX;';
$db['default']['username'] = 'WWWWWW';
$db['default']['password'] = 'YYYYYY';
$db['default']['database'] = 'XXXXXXXXX';
$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;
DOn’t have any idea how to solve it
I think this is an old bug in CI. You have to modify a function _form_tables() in /system/database/drivers/odbc/odbc_driver.php
Hope this will work.