title: How can I use MySQL statement 'show index' with PDO?
body: <p>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:</p>
  
  <pre><code>show index from TABLENAME where Key_name = 'PRIMARY'
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>$pdo = new PDO('mysql:host=localhost;charset=utf8;dbname=eclass', "user", "pass");
  $stm = $pdo-&gt;prepare("show index from `TABLENAME` where `Key_name` = 'PRIMARY'");
  $res = $stm-&gt;execute();
  </code></pre>
  
  <p>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.</p>
  
  <p><strong>EDIT</strong>: It seems that after the weekend, the statement magically works. I don't know why this happened. Thank you for your help.</p>