Get MySQL version in CakePHP 3

You need to import ConnectionManager:

use CakeDatasourceConnectionManager;
$stmt = ConnectionManager::get('default')->query('SELECT version() as v');
$stmt->execute();
echo $stmt->fetch('assoc')['v'];

More on executing CakePHP custom queries, here.

Categories: CakePHP, PHP Tags: , ,
%d bloggers like this: