<?php
$source = '/workspace/zhct/zhctproject/store/application/config/local/database.php';
if (!is_file($source)) {
    throw new RuntimeException('Store local MySQL configuration unavailable');
}
$main = require $source;
$ai = $main['ai_zhct'] ?? [];
foreach ([$main, $ai] as $config) {
    foreach (['hostname', 'database', 'username', 'password'] as $key) {
        if (empty($config[$key])) {
            throw new RuntimeException('Store local MySQL configuration incomplete');
        }
    }
}
return [
    'type' => getenv('POC_FAIL_AI_COMMIT') === '1'
        ? \app\cores\database\FaultMysql::class : 'mysql',
    'hostname' => $main['hostname'],
    'hostport' => (int)($main['hostport'] ?? 3306),
    'database' => $main['database'],
    'username' => $main['username'],
    'password' => $main['password'],
    'charset' => getenv('POC_MYSQL_UTF8MB4') === '1'
        ? 'utf8mb4' : ($main['charset'] ?? 'utf8'),
    'prefix' => 'ydy_',
    'debug' => false,
    'params' => [],
    'resultset_type' => 'array',
    'fields_strict' => true,
    'auto_timestamp' => false,
    'ai_zhct' => [
        'hostname' => $ai['hostname'],
        'hostport' => (int)($ai['hostport'] ?? 3306),
        'database' => $ai['database'],
        'username' => $ai['username'],
        'password' => $ai['password'],
        'prefix' => 'yoshop_',
    ],
];
