webman中如何判断mysql数据表是否存在

macho

laravel 示例

if (Schema::hasTable('users')) {
    // "users" 表存在...
}

if (Schema::hasColumn('users', 'email')) {
    // "users" 表存在,并且有 "email" 列...
}

我的配置

"illuminate/database": "^9.27",
"illuminate/pagination": "^9.27",
"illuminate/events": "^9.27",

代码

use Illuminate\Support\Facades\Schema;

if (Schema::hasTable('users')) {
    // "users" 表存在...
}

结果报错

A facade root has not been set

1481 1 2
1个回答

six

试下

use support\Db;
Db::Schema->hasTable('users');
年代过于久远,无法发表回答
×
🔝