Currently my project is running on
XAMPP Version 1.7.3
Codeigniter Version 2.1.4
SQL-Server - Microsoft SQL Server 2012 (SP4-GDR) (KB4057116) - 11.0.7462.6 (X64)
It was running fine but the database is growing day by day and the performance is also getting slower in the same manner. Besides that, due to few other major concerns we are forced to migrate to SQL-Server. Now the database is completely migrated to SQL-Server from MySQL.
The problem is in the connection Codeigniter -> SQL-Server
while using XAMPP server. I have tried so many codes that is found in the google but none of these working. One I have is
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => 'MSSQLSERVER',
'username' => '',
'password' => '',
'database' => 'test', --changed
'dbdriver' => 'sqlsrv',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
I am a database developer so couldn't make any additions to the code due to lack of ideas. So, can you plese share your ideas to resolve this problem. I am expecting it in detail steps. It’s no problem If I need to upgrade my versions or change anything else, but I can't change the framework itself.
This process was bit easier for me but being a database developer, it gonna bit harder for you. No worries, if you follow the instructions properly then it will work in a single shot
1- Setup CI configuration files and other setup from the following link
https://futbolsalas15.wordpress.com/2014/02/23/7-steps-to-make-sql-server-and-codeigniter-works/
After doing the above changes, It will still remain incomplete in my case and I did the below additional changes
IN FILE: system\database\DB.php
require_once(BASEPATH.'database/DB_driver.php'); --Find this line
$active_record=TRUE; --Add this line below
IN FILE: system\database\DB_driver.php
var $dbdriver = 'mysql'; --Replace `mysql` with `sqlsrv`
SP calling method, suppose you have sp_report with four parameters as below:
--From Mysql
$call_proc = "CALL sp_report('b', 'a', $date_from, $date_to)"
--From SQLServer
$call_proc = "DECLARE @p_report_type CHAR(1) = 'b',
@p_sub_type CHAR(1) = 'a',
@p_date_from VARCHAR(10) = '".$date_from."',
@p_date_to VARCHAR(10) = '".$date_to."'
EXEC sp_report @p_report_type, @p_sub_type, @p_date_from, @p_date_to"
Thats all my friend, hope it will work as expected.