CodeIgniter Forums
CI 3.0 and Microsoft SQL Server nightmare - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: CodeIgniter 3.x (https://forum.codeigniter.com/forumdisplay.php?fid=17)
+--- Thread: CI 3.0 and Microsoft SQL Server nightmare (/showthread.php?tid=61938)



CI 3.0 and Microsoft SQL Server nightmare - Mitteg - 06-01-2015

Hello,

I have recently upgraded to CI 3.0 and now I cannot connecto to my SQL Server database like before. Here is my Config/database file:

CODEIGNITER 2.X.X --> worked flawlessly

Code:
$active_group = 'default';
$active_record = TRUE;

$db['default']['hostname'] = 'XXX';
$db['default']['username'] = 'XXX';
$db['default']['password'] = 'XXX';
$db['default']['database'] = 'XXX';
$db['default']['dbdriver'] = 'mssql';
$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;

CODEIGNITER 3.0 -> error

Code:
$active_group = 'default';
$query_builder = TRUE;

    $db['default'] = array(
        'dsn'   => '',
        'hostname' => 'XXX',
        'username' => 'XXX',
        'password' => 'XXX',
        'database' => 'XXX',
        'dbdriver' => 'mssql',
        'dbprefix' => '',
        'pconnect' => FALSE,
        'db_debug' => TRUE,
        'cache_on' => FALSE,
        'cachedir' => '',
        'char_set' => 'utf8',
        'dbcollat' => 'utf8_general_ci',
        'swap_pre' => '',
        'encrypt' => FALSE,
        'compress' => FALSE,
        'stricton' => FALSE,
        'failover' => array(),
        'save_queries' => TRUE
    );

Here is the error:

Code:
A Database Error Occurred

Unable to set client connection character set: utf8

Filename: core/CodeIgniter.php

Line Number: 500

I also tried a different driver. Here is the error I get if I use the sqlsrv driver:

Code:
A PHP Error was encountered

Severity: Runtime Notice

Message: Declaration of CI_DB_sqlsrv_driver::_limit() should be compatible with that of CI_DB_query_builder::_limit()

Filename: sqlsrv/sqlsrv_driver.php

Line Number: 459

A PHP Error was encountered

Severity: Runtime Notice

Message: Declaration of CI_DB_sqlsrv_driver::_delete() should be compatible with that of CI_DB_query_builder::_delete()

Filename: sqlsrv/sqlsrv_driver.php

Line Number: 459

A PHP Error was encountered

Severity: Runtime Notice

Message: Declaration of CI_DB_sqlsrv_driver::_update() should be compatible with that of CI_DB_driver::_update()

Filename: sqlsrv/sqlsrv_driver.php

Line Number: 459

Any ideas? This is driving me crazy. Thank you!


RE: CI 3.0 and Microsoft SQL Server nightmare - Avenirer - 06-02-2015

Could you try this and tell me if it works?

$db['default']['char_set'] = 'UTF-8';


RE: CI 3.0 and Microsoft SQL Server nightmare - gadelat - 06-02-2015

line 459 of sql_driver is a comment, so your installation is either corrupted or you are extending driver in some hackish, unofficial way


RE: CI 3.0 and Microsoft SQL Server nightmare - ketav - 03-28-2016

I'm getting same error with Codeigniter 3.


RE: CI 3.0 and Microsoft SQL Server nightmare - Narf - 03-29-2016

(06-02-2015, 06:15 AM)gadelat Wrote: line 459 of sql_driver is a comment, so your installation is either corrupted or you are extending driver in some hackish, unofficial way

You're linking to 3.0.0, while the OP hasn't specified a micro-version number, so we have to assume the latest (i.e. 3.0.6), where 459 is the opening brace for the _limit() declaration.

However, that error message still means that the stock CI files have been modified.


RE: CI 3.0 and Microsoft SQL Server nightmare - aralena7 - 10-01-2016

Hi Mitteg

How did you solve this error.. I have gone mad after this, still not able to correct this error , I used this setting in database.php
$db['default']['hostname'] = 'localhost';
//$db['default']['hostname'] = '127.0.0.2';
$db['default']['port'] = 1433;
$db['default']['username'] = 'sa';
$db['default']['password'] = '';
$db['default']['database'] = '';
//$db['default']['dbdriver'] = 'odbc';
$db['default']['dbdriver'] = 'sqlsrv';
$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;

please  help me, waiting.....


RE: CI 3.0 and Microsoft SQL Server nightmare - InsiteFX - 10-03-2016

Here is the information for the newest ms sql driver for php it has php for stand alone testing of database.

READMicrosoft PHP Driver for SQL Server

At least you can test it stand alone to make sure that your database is up  and working.


RE: CI 3.0 and Microsoft SQL Server nightmare - aralena7 - 10-03-2016

(10-03-2016, 04:10 AM)InsiteFX Wrote: Here is the information for the newest ms sql driver for php it has php for stand alone testing of database.

READMicrosoft PHP Driver for SQL Server

At least you can test it stand alone to make sure that your database is up  and working.

InsiteFX thank you so much for replying. I am able to fix this error, Getting the login page but when I click on submit I get this error which is freaking me out:
A PHP Error was encountered
Severity: Warning
Message: sqlsrv_query() expects parameter 1 to be resource, null given
Filename: sqlsrv/sqlsrv_driver.php
Line Number: 152

I have odbc server native client (odbc driver 13). I have spent a lot of time on this. It would be great if you could help me fix this error . Please


RE: CI 3.0 and Microsoft SQL Server nightmare - InsiteFX - 10-04-2016

Parameter 1 should be your database connection id.

You can try passing it into your query:

Parameter 1:
PHP Code:
$this->db->conn_id