【发布时间】:2015-11-18 12:18:42
【问题描述】:
我想知道 mysql 表中是否存在特定列。我在较旧的帖子中搜索了解决方案,但没有任何运气:
- Check if column exist in Mysql table via php
- How can I check if mysql table column even exists?
- MySQL, Check if a column exists in a table with SQL
- Check if column exists, if not, add in MySQL through PHP
我想知道的是PHP的MySQLi类中是否有任何方法可以做到这一点?
问的原因是我现在的项目是基于PHP中的MySQLi类的。
我已经尝试过通过查询“information_schema”数据库来完成工作的旧方法,但由于某种原因,它没有成果。另外,我更喜欢 MySQLi 类的 PHP 内置方法来执行我的所有任务。
【问题讨论】:
-
information_schema.COLUMNS如果列存在则返回一行,否则返回空结果