当前位置:网站首页>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
- JVM instruction mnemonic
- Say goodbye to 996. What are the necessary plug-ins in idea?
- ClassFile - Attributes - Code
- Typeerror: X () got multiple values for argument 'y‘
- Chrome视频下载插件–Video Downloader for Chrome
- Watermelon book -- Chapter 6 Support vector machine (SVM)
- 破茧|一文说透什么是真正的云原生
- 【Go实战基础】如何安装和使用 gin
- Redis 序列化 GenericJackson2JsonRedisSerializer和Jackson2JsonRedisSerializer的区别
猜你喜欢
Jd.com interviewer asked: what is the difference between using on or where in the left join association table and conditions
微服务实战|Eureka注册中心及集群搭建
DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
Number structure (C language -- code with comments) -- Chapter 2, linear table (updated version)
Cloudreve自建云盘实践,我说了没人能限制得了我的容量和速度
Chrome用户脚本管理器-Tampermonkey 油猴
微服务实战|手把手教你开发负载均衡组件
Programmers with ten years of development experience tell you, what core competitiveness do you lack?
Matplotlib剑客行——初相识Matplotlib
Flink-使用流批一体API统计单词数量
随机推荐
Enterprise level SaaS CRM implementation
"Redis source code series" learning and thinking about source code reading
In depth analysis of how the JVM executes Hello World
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
使用IBM MQ远程连接时报错AMQ 4043解决思路
知识点很细(代码有注释)数构(C语言)——第三章、栈和队列
DTM distributed transaction manager PHP collaboration client V0.1 beta release!!!
Microservice practice | load balancing component and source code analysis
Chrome video download Plug-in – video downloader for Chrome
以字节跳动内部 Data Catalog 架构升级为例聊业务系统的性能优化
AMQ 4043 solution for errors when using IBM MQ remote connection
分布式服务架构精讲pdf文档:原理+设计+实战,(收藏再看)
【Go实战基础】gin 如何自定义和使用一个中间件
定时线程池实现请求合并
Talk about the secret of high performance of message queue -- zero copy technology
Discussion on improving development quality and reducing test bug rate
[go practical basis] how can gin get the request parameters of get and post
Taking the upgrade of ByteDance internal data catalog architecture as an example, talk about the performance optimization of business system