使用PDO获取MySQL服务器版本 [英] Get MySQL Server Version with PDO
问题描述
我正在Laravel 5中构建一个应用程序,我需要确保我的一个表能够执行FULLTEXT搜索.
I'm building out an app in Laravel 5 and I need to ensure that one of my tables will be able to perform FULLTEXT searches.
我想检测MySQL版本号(确保其至少为5.6.10或更高版本),以便在该条件失败的情况下,可以在给定表的迁移文件中将引擎切换为MyISAM.
I'd like to detect the MySQL version number(ensuring it's at least 5.6.10 or above) so that I can switch the engine to MyISAM in my migration file for a given table, if that condition fails.
我似乎找不到任何有关如何使用PDO访问MySQL服务器信息的文档,这是Laravel开箱即用的内容.
I can't seem to find any docs on how to access the MySQL server info using PDO, which is what Laravel uses out of the box.
感谢您的帮助.
推荐答案
为什么不只运行select version();
查询,无论您使用的是哪种API,这都会为您提供所有正确的结果?
Why not just run select version();
query, which will give you all-correct result no matter which API you are using?
echo $pdo->query('select version()')->fetchColumn();
这篇关于使用PDO获取MySQL服务器版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!