gpt4 book ai didi

php - CodeIgniter 3.0.6 中的 SQLite3

转载 作者:IT王子 更新时间:2023-10-29 06:27:23 26 4
gpt4 key购买 nike

我找不到任何关于如何在 CodeIgniter 中使用 sqlite3 的文档,但它确实说它受支持。

这是我当前的数据库配置:

$db['default']['hostname'] = '';
$db['default']['username'] = '';
$db['default']['password'] = '';
$db['default']['database'] = 'db/base.db';
$db['default']['dbdriver'] = 'sqlite3';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$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;

但是我在页面加载时遇到了一个非常难以描述的错误

Unable to connect to your database server using the provided settings.

Filename: core/CodeIgniter.php

Line Number: 500

所以我的问题是,为什么我的配置不起作用,我该如何让它起作用?

最佳答案

你使用的是 CI2 语法,我不知道你从哪里得到它,因为在默认包中你可以找到与下面相同的代码,你只需要定义的是 database (路径到db) 和 dbdriver

$db['default'] = array(
'dsn' => '',
'hostname' => '',
'username' => '',
'password' => '',
'database' => './application/database/data.db',
'dbdriver' => 'sqlite3',
'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
);

或者你可以使用它(使用需要 dsn 字符串的 PDO 数据库驱动程序,否则 CI 将尝试构建它)

$db['default'] = array(
'dsn' => 'sqlite:application/database/data.db',// path/to/database
'hostname' => '',
'username' => '',
'password' => '',
'database' => '',
'dbdriver' => 'pdo',
'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
);

关于php - CodeIgniter 3.0.6 中的 SQLite3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37079746/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com