2

簡単な質問です。Codeigniter 2.xx では、MS SQLServer データベースへの接続に問題はありませんでした。Codeigniter 3 にアップグレードしたところ、次のエラーが発生しました。

A Database Error Occurred

Unable to set client connection character set: utf8

Filename: core/CodeIgniter.php

Line Number: 500

ここに私のdatabase.php設定ファイルがあります:

Codeigniter 2.xx --> 動作します

$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 --> エラー

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

何か案は?ありがとう。

さらにテストにはsqlsrvドライバーの使用が含まれますが、次のエラーが発生します。

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
4

1 に答える 1

1

私はこれをやってしまった:

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

$db['default'] = array(
    'dsn'   => 'Driver={SQL Server Native Client 10.0};Server=XXX.XX.XXX.XXX;Database=myDataBaseName;',
    'hostname' => '',
    'username' => 'XXX',
    'password' => 'XXX',
    'database' => '',
    'dbdriver' => 'odbc',
    '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
);

それは完璧に動作します。とにかくヒントをありがとう。

于 2015-06-03T11:53:01.793 に答える