laravel使用artisan报错SQLSTATE[42S02]: Base table or view not found: 1146
说明你在应用初始化阶段使用到了数据库层面的东西,然而当时数据库不存在这个表/字段,所以会报错
需要在初始化比如 config 目录配置中,使用了数据库,在使用前需要添加一层判断,如果不存在 你需要用到的 表/字段 就跳过执行,或者给个初始值
判断是否存在某个表
if ( ! Schema::hasTable('table_name')) {
// 创建数据库表的代码
}
判断表中是否存在某个字段
if (Schema::hasColumn('users', 'email'))
{
// users表 中email字段
}
laravel使用artisan报错SQLSTATE[42S02]: Base table or view not found: 1146的更多相关文章
- thinkphp中SQLSTATE[42S02]: Base table or view not found: 1146 Table错误解决方法
随手记录下今天在thinkphp3.2.3中遇到的错误SQLSTATE[42S02]: Base table or view not found: 1146 Table 'test.file_info ...
- Laravel 5.2错误-----Base table or view not found: 1146 Table
报出这个问题,我想就是数据库表名不对导致的. 为什么呢?感觉laravel太强大了,很专业的感觉. 因为它对单词命名的单复数区分的很清楚吧.laravel会自动的将模型名自动替换成名称的复数形式,然后 ...
- SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'xxx' already exists
字面意思 xxx表已存在. 在使用laravel 写同步结构的时候 最好习惯性写个if语句判定是否存在 // 判断数据表是否存在 Schema::hasTable('table'); // 判断数据 ...
- Base table or view not found
项目 代码分细致 改为Logic, Model, Controller ,View 四个模块 $model=D("Index",'Logic'); $res=$model-> ...
- Laravel5.x的php artisan migrate数据库迁移创建操作报错SQLSTATE[42000]解决
Laravel5.x运行迁移命令创建数据表:php artisan migrate报错. Illuminate\Database\QueryException : SQLSTATE[42000]: ...
- laravel安装一直报错
laravel安装一直报错 原因: 1.找到php版本是否对应 2.缺少第三方扩展库vendor 需要composer update 解决链接:https://learnku.com/docs/lar ...
- Laravel 5.1 报错:[App\Http\Requests\Request] is not instantiable
Laravel 5.1 报错:[App\Http\Requests\Request] is not instantiable 错误提示: Whoops, looks like something we ...
- 解决 Class not found和Base table or view not found: 1051 问题
1.解决class not found的方法: 如果你用的是homestead虚拟机,那么,你要到虚拟机下执行: composer dump-autoload 2.解决Base table or vi ...
- magento -- 解决magento错误:ERROR: Base table or view already exists: 1050 Table ... already exists
相信有更新magento或者,备份转移magento站点的时候可能会碰到类似这样的错误提示: Base table or view already exists: 1050 Table ... alr ...
随机推荐
- 表格变色示例中发现的问题——attr()与prop()
在练习jQuery表格变色例子过程中,发现了一下几个问题: 在IEEdge浏览器中切换选中行会出现上一个表格行背景色被吃掉的情况: 在chrome中从上向下单击行中任意单元可以选中该行,而从下往上单击 ...
- netserver启动时报错 "Unable to start netserver with 'IN(6)ADDR_ANY' port '12865' and family AF_UNSPEC'"
netperf启动netserver时报错 "Unable to start netserver with 'IN(6)ADDR_ANY' port '12865' and family A ...
- nginx 启动关闭
#检查语法 /application/nginx/sbin/nginx –t #平滑重启 /application/nginx/sbin/nginx –s reload #不间断服务重启,将 pid ...
- losetup - 设 定 与 控 制 环回设备
总览 SYNOPSIS losetup [ -e encryption ] [ -o offset ] loop_device file losetup [ -d ] loop_device 描述 l ...
- Protobuf(一)——Protobuf简介
Protobuf简介 什么是 Google Protocol Buffer? 假如您在网上搜索,应该会得到类似这样的文字介绍: Google Protocol Buffer( 简称 Proto ...
- Win10遇到蓝屏错误CRITICAL_STRUCTURE_CORRUPTION如何解决
很多使用win10系统的用户,都曾经遇到过蓝屏故障.比如,最近有位win10用户在使用电脑时,就发现电脑突然出现了蓝屏,且提示错误CRITICAL_STRUCTURE_CORRUPTION,这是怎么回 ...
- python 导入模块、包
1. 模块:一个有逻辑的python文件,包含变量.函数.类等.2. 包:一个包含__init__.py的文件夹,存放多个模块 import 本质是路径搜索,查找sys.path下有无你导入的 pac ...
- AngularJS中forEach的用法
AngularJS中当我们需要遍历某个数组的时候,我们会用到forEach语法.AngularJS中forEach的用法如下: angular.forEach(array,function(obj,i ...
- Java大文件上传详解及实例代码
1,项目调研 因为需要研究下断点上传的问题.找了很久终于找到一个比较好的项目. 在GoogleCode上面,代码弄下来超级不方便,还是配置hosts才好,把代码重新上传到了github上面. http ...
- 跳马(Knight Moves), ZOJ1091, POJ2243 x
跳马(Knight Moves), ZOJ1091, POJ2243 题目描述: 给定象棋棋盘上两个位置 a 和 b,编写程序,计算马从位置 a 跳到位置 b 所需步数的最小值. 输入描述: 输入文件 ...