Dit werkte als een tierelier!
$db->query('set profiling=1'); //optional if profiling is already enabled
$db->query($_POST['query']);
$stmt = $db->query('show profiles');
$db->query('set profiling=0'); //optional as well
$records = $stmt->fetchAll(PDO::FETCH_ASSOC);
$errmsg = $stmt->errorInfo()[2]; //Output the error message
UPDATE (Het volgende werkt nu op innodb op mijn huidige setup)
$db->query('set profiling=1'); //optional if profiling is already enabled
$db->query($_POST['query']);
$res = $db->query('show profiles');
$records = $res->fetchAll(PDO::FETCH_ASSOC);
$duration = $records[0]['Duration']; // get the first record [0] and the Duration column ['Duration'] from the first record
Resultaat van (profielen weergeven) van phpmyadmin.
Query_ID Duration Query
1 0.00010575 SELECT DATABASE()