CodeIgniter中Database.php配置文件详细介绍

字段名称 介绍
dsn DSN 连接字符串(该字符串包含了所有的数据库配置信息)
hostname 数据库的主机名,通常位于本机,可以表示为 “localhost”
username 需要连接到数据库的用户名
password 登陆数据库的密码
database 需要连接的数据库名
dbdriver 数据库类型,必须为小写字母
dbprefix 当使用查询构造器查询时,可以选择性的为表加个前缀,它允许在一个数据库上安装多个 CodeIgniter 程序
pconnect 是否使用持续连接
db_debug 是否显示数据库错误信息
cache_on 是否开启数据库查询缓存
cachedir 数据库查询缓存目录所在的服务器绝对路径
char_set 与数据库通信时所使用的字符集
dbcollat 与数据库通信时所使用的字符规则,注意:只使用于’mysql’和’mysqli’数据库驱动
swap_pre 替换默认的 dbprefix 表前缀,该项设置对于分布式应用是非常有用的,你可以在查询中使用由最终用户定制的表前缀
encrypt 是否使用加密连接
compress 是否使用客户端压缩协议(只用于MySQL)
stricton 是否强制使用 “Strict Mode” 连接, 在开发程序时,使用 strict SQL 是一个好习惯
failover 当主数据库由于某些原因无法连接时,你还可以配置故障转移(failover)
save_queries 是否“保存”所有已执行的查询
/*
|	['dsn']      The full DSN string describe a connection to the database.
|	['hostname'] The hostname of your database server.
|	['username'] The username used to connect to the database
|	['password'] The password used to connect to the database
|	['database'] The name of the database you want to connect to
|	['dbdriver'] The database driver. e.g.: mysqli.
|			Currently supported:
|				 cubrid, ibase, mssql, mysql, mysqli, oci8,
|				 odbc, pdo, postgre, sqlite, sqlite3, sqlsrv
|	['dbprefix'] You can add an optional prefix, which will be added
|				 to the table name when using the  Query Builder class
|	['pconnect'] TRUE/FALSE - Whether to use a persistent connection
|	['db_debug'] TRUE/FALSE - Whether database errors should be displayed.
|	['cache_on'] TRUE/FALSE - Enables/disables query caching
|	['cachedir'] The path to the folder where cache files should be stored
|	['char_set'] The character set used in communicating with the database
|	['dbcollat'] The character collation used in communicating with the database
|				 NOTE: For MySQL and MySQLi databases, this setting is only used
| 				 as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7
|				 (and in table creation queries made with DB Forge).
| 				 There is an incompatibility in PHP with mysql_real_escape_string() which
| 				 can make your site vulnerable to SQL injection if you are using a
| 				 multi-byte character set and are running versions lower than these.
| 				 Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
|	['swap_pre'] A default table prefix that should be swapped with the dbprefix
|	['encrypt']  Whether or not to use an encrypted connection.
|
|			'mysql' (deprecated), 'sqlsrv' and 'pdo/sqlsrv' drivers accept TRUE/FALSE
|			'mysqli' and 'pdo/mysql' drivers accept an array with the following options:
|
|				'ssl_key'    - Path to the private key file
|				'ssl_cert'   - Path to the public key certificate file
|				'ssl_ca'     - Path to the certificate authority file
|				'ssl_capath' - Path to a directory containing trusted CA certificates in PEM format
|				'ssl_cipher' - List of *allowed* ciphers to be used for the encryption, separated by colons (':')
|				'ssl_verify' - TRUE/FALSE; Whether verify the server certificate or not
|
|	['compress'] Whether or not to use client compression (MySQL only)
|	['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
|							- good for ensuring strict SQL while developing
|	['ssl_options']	Used to set various SSL options that can be used when making SSL connections.
|	['failover'] array - A array with 0 or more data for connections if the main should fail.
|	['save_queries'] TRUE/FALSE - Whether to "save" all executed queries.
*/

猜你喜欢

转载自blog.csdn.net/qq_41784169/article/details/107838327
今日推荐