我想使用SQL Server配置CI4连接。 如果在CI3中
$db['dbsqlsrv'] = array(
'dsn' => '',
'hostname' => 'localhost',
'port' => '1433',
'username' => 'sa',
'password' => 'example',
'database' => 'example',
'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
);
如何配置此选项以在CI4中工作。因为当我将.env database.default.DBDriver = MySQLi更新为database.default.DBDriver = Mssql无法工作时。
答案 0 :(得分:-1)
要在codeigniter 4中使用mysql数据库,应保留。对于mysql,应保留以下更改。 在.env文件中
database.default.DBDriver = MySQLi
在app / Config / Database.php
中public $default = [
...
DBDriver=>'MySQLi',
...
];
答案 1 :(得分:-1)
CodeIgniter 4
在应用程序>>配置>> Database.php
检查 $ defaultGroup 值
public $defaultGroup = 'default';
public $default = [
'DSN' => '',
'hostname' => 'localhost',
'username' => 'YOUR_USER',
'password' => 'YOUR_PASSWORD',
'database' => 'DATABASE_NAME',
'DBDriver' => 'MySQLi',
'DBPrefix' => '',
'pConnect' => false,
'DBDebug' => (ENVIRONMENT !== 'production'),
'cacheOn' => false,
'cacheDir' => '',
'charset' => 'utf8',
'DBCollat' => 'utf8_general_ci',
'swapPre' => '',
'encrypt' => false,
'compress' => false,
'strictOn' => false,
'failover' => [],
'port' => 3308,
];