当前位置:网站首页>Thinkphp5 how to determine whether a table exists
Thinkphp5 how to determine whether a table exists
2022-07-02 09:26:00 【Yisu cloud】
thinkphp5 How to judge whether a table exists
This article mainly shows you “thinkphp5 How to judge whether a table exists ”, The content is simple and easy to understand , Clarity of organization , I hope I can help you solve your doubts , Now let Xiaobian lead you to study and learn “thinkphp5 How to judge whether a table exists ” This is the article .
Method :1、 use “$a=M()->query('SHOW TABLES LIKE" Table name "');if($a){ There is }else{ Table does not exist }” Judge ;2、 use “$a=M( Table name );if($a->getDbError()){ Table does not exist }else{ There is }” Judge .
This article describes the operating environment :Windows10 System 、ThinkPHP5 edition 、Dell G3 The computer .
thinkphp5 How to judge whether a table exists
thinkphp Framework is a very easy-to-use and powerful framework , It is the development habit of our people . So in use thinkphp Frame time , Sometimes there's a need , It is necessary to judge whether a database table exists .
ad locum , We assume judgment users Does the table exist :
$users = M('users');
if($users->getDbError()){
echo ' Data table does not exist !';
}else{
echo ' The database exists !';
}Method 2:
$isTable = M()->query('SHOW TABLES LIKE "table_name"');
if( $isTable ){
echo ' Table exists ';
}else{
echo ' Table does not exist ';
}Above is “thinkphp5 How to judge whether a table exists ” All the content of this article , Thank you for reading ! I believe we all have a certain understanding , I hope the content shared will be helpful to you , If you want to learn more , Welcome to the Yisu cloud industry information channel !
边栏推荐
- WSL installation, beautification, network agent and remote development
- Complete solution of servlet: inheritance relationship, life cycle, container, request forwarding and redirection, etc
- AMQ 4043 solution for errors when using IBM MQ remote connection
- 微服务实战|手把手教你开发负载均衡组件
- Attributes of classfile
- 知识点很细(代码有注释)数构(C语言)——第三章、栈和队列
- 队列管理器running状态下无法查看通道
- The channel cannot be viewed when the queue manager is running
- 【Go实战基础】如何安装和使用 gin
- Demand delineation executive summary
猜你喜欢

我服了,MySQL表500W行,居然有人不做分区?

Chrome浏览器标签管理插件–OneTab

Hystrix implements request consolidation
![[staff] the lines and spaces of the staff (the nth line and the nth space in the staff | the plus N line and the plus N space on the staff | the plus N line and the plus N space below the staff | the](/img/dc/c0ea188ef353ded86759dbe9b29df3.jpg)
[staff] the lines and spaces of the staff (the nth line and the nth space in the staff | the plus N line and the plus N space on the staff | the plus N line and the plus N space below the staff | the

机器学习实战:《美人鱼》属于爱情片还是动作片?KNN揭晓答案

Chrome浏览器插件-Fatkun安装和介绍

WSL安装、美化、网络代理和远程开发

Number structure (C language) -- Chapter 4, compressed storage of matrices (Part 2)

Redis installation and deployment (windows/linux)

WSL installation, beautification, network agent and remote development
随机推荐
知识点很细(代码有注释)数构(C语言)——第三章、栈和队列
Matplotlib剑客行——初相识Matplotlib
DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
「Redis源码系列」关于源码阅读的学习与思考
Matplotlib swordsman - a stylist who can draw without tools and code
Matplotlib swordsman line - first acquaintance with Matplotlib
机器学习之数据类型案例——基于朴素贝叶斯法,用数据辩男女
Programmers with ten years of development experience tell you, what core competitiveness do you lack?
AMQ 4043 solution for errors when using IBM MQ remote connection
《统计学习方法》——第五章、决策树模型与学习(上)
Redis 序列化 GenericJackson2JsonRedisSerializer和Jackson2JsonRedisSerializer的区别
长篇总结(代码有注释)数构(C语言)——第四章、串(上)
Chrome视频下载插件–Video Downloader for Chrome
[staff] time sign and note duration (full note | half note | quarter note | eighth note | sixteenth note | thirty second note)
WSL installation, beautification, network agent and remote development
Demand delineation executive summary
Matplotlib swordsman line - layout guide and multi map implementation (Updated)
Dix ans d'expérience dans le développement de programmeurs vous disent quelles compétences de base vous manquez encore?
cmd窗口中中文呈现乱码解决方法
概念到方法,绝了《统计学习方法》——第三章、k近邻法