有没有办法检测Laravel是否存在数据库表 [英] Is there any way to detect if a database table exists with Laravel
本文介绍了有没有办法检测Laravel是否存在数据库表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够使用创建表
Schema::create('mytable',function($table)
{
$table->increments('id');
$table->string('title');
});
但是在此之前,我想检查表是否已经存在,也许是类似的
But before that I would like to check if the table already exists, perhaps something like
Schema::exists('mytable');
但是,以上功能不存在.我还能使用什么?
However, the above function does not exist. What else can I use?
推荐答案
如果您使用的是Laravel 4或5,则有hasTable()
方法,您可以找到它 L5文档:
If you are using Laravel 4 or 5 then there is the hasTable()
method, you can find it in the L4 source code or the L5 docs:
Schema::hasTable('mytable');
这篇关于有没有办法检测Laravel是否存在数据库表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文