|
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Api;
|
|
|
|
|
|
use App\Service\Box\BoxService;
|
|
|
use App\Service\ProductionOrderService;
|
|
|
+use Illuminate\Support\Facades\Config;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
class TestController extends BaseController
|
|
@@ -19,9 +20,56 @@ class TestController extends BaseController
|
|
|
dd(1);
|
|
|
}
|
|
|
public function tt(){
|
|
|
- $db = DB::connection("mysql_001");
|
|
|
- $u8 = $db->table('sys_config')
|
|
|
+// $db = DB::connection("mysql_001");
|
|
|
+// $u8 = $db->table('sys_config')
|
|
|
+// ->first();
|
|
|
+// dd($u8);
|
|
|
+
|
|
|
+ $model_box = DB::connection("mysqlT9");
|
|
|
+ $u8 = $model_box->table('setting')
|
|
|
+ ->where('setting_name','u8')
|
|
|
+ ->where('setting_value','<>','')
|
|
|
->first();
|
|
|
- dd($u8);
|
|
|
+ if(empty($u8)) return [false, 'u8配置参数不存在!'];
|
|
|
+
|
|
|
+ $u8 = $u8->setting_value;
|
|
|
+ // 使用 eval() 函数执行字符串并转换为数组
|
|
|
+ $u8 = eval("return {$u8};");
|
|
|
+ if(empty($u8['domain'])) return [false, '外部域名不能为空!'];
|
|
|
+ if(empty($u8['u8_api_port'])) return [false, 'u8程序API端口不能为空!'];
|
|
|
+ if(empty($u8['u8_database_port'])) return [false, 'u8程序数据库端口不能为空!'];
|
|
|
+ if(empty($u8['database'])) return [false, 'u8程序数据库不能为空!'];
|
|
|
+ if(empty($u8['database_account'])) return [false, 'u8程序数据库登录账号不能为空!'];
|
|
|
+ if(empty($u8['database_password'])) return [false, 'u8程序数据库登录密码不能为空!'];
|
|
|
+ if(empty($u8['sAccID'])) return [false, 'u8程序sAccID不能为空!'];
|
|
|
+ if(empty($u8['sServer'])) return [false, 'u8程序sServer不能为空!'];
|
|
|
+ if(empty($u8['sUserID'])) return [false, 'u8程序sUserID不能为空!'];
|
|
|
+ if(empty($u8['sPassword'])) return [false, 'u8程序sPassword不能为空!'];
|
|
|
+
|
|
|
+ $config = [
|
|
|
+ 'driver' => 'sqlsrv',
|
|
|
+ 'host' => $u8['domain'],
|
|
|
+ 'port' => $u8['u8_database_port'],
|
|
|
+ 'database' => $u8['database'],
|
|
|
+ 'username' => $u8['database_account'],
|
|
|
+ 'password' => $u8['database_password'],
|
|
|
+ ];
|
|
|
+
|
|
|
+ // 数据库配置设置
|
|
|
+ Config::set('database.connections.sqlsrvs', $config);
|
|
|
+
|
|
|
+ // 连接
|
|
|
+ try {
|
|
|
+ $pdo = DB::connection('sqlsrvs')->getPdo();
|
|
|
+ if ($pdo instanceof \PDO) {
|
|
|
+ // 连接成功的逻辑代码
|
|
|
+ $db = DB::connection('sqlsrvs');
|
|
|
+ dd(111);
|
|
|
+ } else {
|
|
|
+ dd(1233);
|
|
|
+ }
|
|
|
+ } catch (\Throwable $e) {
|
|
|
+ dd($e->getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
}
|