ProjectDatabaseUpdate.php
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2023/4/19
* Time: 15:04
*/
namespace App\Console\Commands;
use App\Models\Project;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
/**
* Class ProjectDatabaseUpdate
* @package App\Console\Commands
*/
class ProjectDatabaseUpdate extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'project:database_update';
/**
* The console command description.
*
* @var string
*/
protected $description = '项目数据库更新';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* @return bool
*/
public function handle()
{
#TODO 未处理更新 更新对象(base, project) 更新内容
return true;
}
/**
* 主库内容更新
* @param $sql
* @return array
*/
public function baseUpdate($sql)
{
return DB::select($sql);
}
/**
* 客户数据表更新
* @param $sql
* @return bool
*/
public function projectDatabaseUpdate($sql)
{
$project = Project::get();
foreach ($project as $val) {
ProjectServer::useProject($val->id);
DB::connection('custom_mysql')->select($sql);
}
return true;
}
/**
* 指定项目数据库更新
* @param $project_id
* @param $sql
*/
public function appointProjectUpdate($project_id, $sql)
{
ProjectServer::useProject($project_id);
DB::connection('custom_mysql')->select($sql);
}
}