Files
crm-server/config/database.php
T
2025-04-01 17:32:08 +08:00

81 lines
3.7 KiB
PHP

<?php
return [
// 默认数据库
'default' => 'mysql',
// 各种数据库配置
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => getenv('DB_HOST'),
'port' => getenv('DB_PORT'),
'database' => getenv('DB_NAME'),
'username' => getenv('DB_USER'),
'password' => getenv('DB_PASSWORD'),
'unix_socket' => '',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
'pool' => [ // 连接池配置,仅支持swoole/swow驱动
'max_connections' => 5, // 最大连接数
'min_connections' => 1, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待的最大时间,超时后会抛出异常
'idle_timeout' => 60, // 连接池中连接最大空闲时间,超时后会关闭回收,直到连接数为min_connections
'heartbeat_interval' => 50, // 连接池心跳检测时间,单位秒,建议小于60秒
],
],
/*'sqlite' => [
'driver' => 'sqlite',
'database' => '',
'prefix' => '',
'pool' => [ // 连接池配置,仅支持swoole/swow驱动
'max_connections' => 5, // 最大连接数
'min_connections' => 1, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待的最大时间,超时后会抛出异常
'idle_timeout' => 60, // 连接池中连接最大空闲时间,超时后会关闭回收,直到连接数为min_connections
'heartbeat_interval' => 50, // 连接池心跳检测时间,单位秒,建议小于60秒
],
],
'pgsql' => [
'driver' => 'pgsql',
'host' => '127.0.0.1',
'port' => 5432,
'database' => 'webman',
'username' => 'webman',
'password' => '',
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
'pool' => [ // 连接池配置,仅支持swoole/swow驱动
'max_connections' => 5, // 最大连接数
'min_connections' => 1, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待的最大时间,超时后会抛出异常
'idle_timeout' => 60, // 连接池中连接最大空闲时间,超时后会关闭回收,直到连接数为min_connections
'heartbeat_interval' => 50, // 连接池心跳检测时间,单位秒,建议小于60秒
],
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => 'localhost',
'port' => 1433,
'database' => 'webman',
'username' => 'webman',
'password' => '',
'charset' => 'utf8',
'prefix' => '',
'pool' => [ // 连接池配置,仅支持swoole/swow驱动
'max_connections' => 5, // 最大连接数
'min_connections' => 1, // 最小连接数
'wait_timeout' => 3, // 从连接池获取连接等待的最大时间,超时后会抛出异常
'idle_timeout' => 60, // 连接池中连接最大空闲时间,超时后会关闭回收,直到连接数为min_connections
'heartbeat_interval' => 50, // 连接池心跳检测时间,单位秒,建议小于60秒
],
],*/
],
];