I am trying to use PDO and prepared statements to get the primary key of a table. From other questions I saw that this is possible when executing something like this:
show index from TABLENAME where Key_name = 'PRIMARY'
The problem is that I can not use this from inside a prepared statement by using PDO under PHP. The code I use is the following:
$pdo = new PDO('mysql:host=localhost;charset=utf8;dbname=eclass', "user", "pass"); $stm = $pdo->prepare("show index from `TABLENAME` where `Key_name` = 'PRIMARY'"); $res = $stm->execute();
Now, the problem is that although the statement is created correctly, the execution fails. I am sure that this is not a permission's problem, since I run this as root with no result. When I directly run this SQL code from mysql prompt, it shows result indeed.
EDIT: It seems that after the weekend, the statement magically works. I don't know why this happened. Thank you for your help.