MySQLi 中是否有任何方法来检查列是否存在?
Is there any method or so in MySQLi to check if a column exists?
我想知道 mysql table 中是否存在特定列。我在较旧的帖子中搜索了解决方案,但没有任何运气:
- 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的MySQLiclass有没有方法可以做到这一点?
之所以问是因为我现在的项目是基于PHP中的MySQLiclass。
我尝试了通过查询“information_schema
”的数据库来完成工作的旧方法,但由于某种原因,它没有取得成果。此外,我更喜欢 PHP MySQLi class 的内置方法来执行我的所有任务。
有一个MySQL查询来获取列信息:
show columns from `table`;
这里有更多关于它的文档:https://dev.mysql.com/doc/refman/5.7/en/show-columns.html
我想知道 mysql table 中是否存在特定列。我在较旧的帖子中搜索了解决方案,但没有任何运气:
- 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的MySQLiclass有没有方法可以做到这一点?
之所以问是因为我现在的项目是基于PHP中的MySQLiclass。
我尝试了通过查询“information_schema
”的数据库来完成工作的旧方法,但由于某种原因,它没有取得成果。此外,我更喜欢 PHP MySQLi class 的内置方法来执行我的所有任务。
有一个MySQL查询来获取列信息:
show columns from `table`;
这里有更多关于它的文档:https://dev.mysql.com/doc/refman/5.7/en/show-columns.html