sql - laravel DB连接中的数组到字符串转换
问题描述
我正在尝试修复有问题的代码导致数组到字符串的转换,但我找不到问题。
这是一个名为“blessing-skin”的程序的插件配置代码,我试图修改多个数组但它无效。
<?php
$targetDbConfigForm = Option::form('connection', 'database setting', function ($form) {
$form->text('forum_db_config[host]', 'TargetSqlAddress')->hint('There may be a delay in interfacing between database hosts, so please be aware.');
$form->text('forum_db_config[port]', 'port');
$form->text('forum_db_config[database]', 'database');
$form->text('forum_db_config[username]', 'username');
$form->text('forum_db_config[password]', 'password');
$form->text('forum_db_config[table]', 'table');
$form->select('forum_duplicated_prefer', 'duplicated prefer')
->option('remote', 'Use remote data')
->option('local', 'Use local data')
->description('After this selection, if the user data (such as the same user name and different username and password) conflicts, the option you choose will be used, and the user data of the other party will be overwritten.');
})->handle()->always(function ($form) {
$config = request('forum_db_config');
if ($config) {
option(['forum_db_config' => serialize($config)]);
} else {
$config = @unserialize(option('forum_db_config'));
}
config(['database.connections.remote' => array_merge(
forum_get_default_db_config(), (array) $config
)]);
try {
DB::connection('remote')->getPdo();
if (Schema::connection('remote')->hasTable($config['table'])) {
$form->addMessage('Connected', 'success');
} else {
$form->addMessage("Connected to databse,but table [{$config['table']}] not found.", 'warning');
}
} catch (Exception $e) {
$form->addMessage('Cannot connect to MySQL server. <br>Error info: '.$e->getMessage(), 'danger');
}
});
?>
找出数组到字符串转换的原因。
解决方案
推荐阅读
- vba - 未应用 Outlook 中的 VBA
- python - 将函数应用于python中的数据框
- python - 我如何增加seaborn Y轴步长
- maven - Maven:如何通过参数下载和不下载Artifact Sources|Javadoc进行编译?
- python - 使用 http get 请求下载 csv?
- notepad++ - 在记事本++中的其他多行之后插入多行
- python - 为 Dask.DataFrame 中的列赋值
- jquery-ui-sortable - SortableJS 没有落在动态创建的空列表上
- javascript - Discord 审核日志
- javascript - 如何在输入框中添加单个字母过滤器