Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get MySQL Server Version with PDO

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.

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.

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.

Any help is appreciated.

like image 752
Vince Kronlein Avatar asked Aug 26 '26 03:08

Vince Kronlein


1 Answers

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();

is throwing me not a single error

like image 193
Your Common Sense Avatar answered Aug 27 '26 17:08

Your Common Sense