title: Converting MYSQL connection to PDO
body: <p>I have been trying to run my stored procedure using mysql for quite sometime. whenever I use the code below</p>
  
  <pre><code>$link_id = DbConnection::getInstance('mycon')-&gt;connectMysql();
  
  $table_count = mysql_query("SELECT TABLE_NAME FROM information_schema.tables WHERE table_schema = 'mycon' AND table_name LIKE 'table_%' ")
  
  while($row = mysql_fetch_array($table_count)){
  $table = $row["TABLE_NAME"];
       $excute = mysql_query("dummy_2('$table')") or die(mysql_error());
       $result = mysql_fetch_assoc($excute);
       var_dump($result);
  }
  </code></pre>
  
  <p>it gives an error saying</p>
  
  <pre><code>Commands out of sync; you can't run this command now
  </code></pre>
  
  <p>Therefore i tried to get this done through <strong>PDO</strong> .. nevertheless i still getting number of errors since im new in it.</p>
  
  <p><strong>code that i tried.</strong></p>
  
  <pre><code>$pdo =new PDO(DbConnection::getInstance('mycon')-&gt;connectMysql());
      if($pdo-&gt;exec("call dummy_2('$table')"))
      {
          echo "its working";
  
      }
  </code></pre>
  
  <p>can any body help me to get the above connection and query done through PDO</p>
  
  <p><strong>connection</strong></p>
  
  <pre><code>$link_id = DbConnection::getInstance('mycon')-&gt;connectMysql();
  </code></pre>
  
  <p><strong>related script</strong></p>
  
  <p>
  
  <pre><code>protected $dbConfig;
  
  protected $dbConfigName;
  
  protected $mysql;
  protected function __construct($dbConfigName){
      $this-&gt;dbConfigName = $dbConfigName;
      $this-&gt;dbConfig = Config_Reader::read($dbConfigName, 'db_con.ini')-&gt;database;
  }
  
  public static function getInstance($dbConfigName){
      if (!isset(self::$instances[$dbConfigName])){
          self::$instances[$dbConfigName] = new self($dbConfigName);
      }
      return self::$instances[$dbConfigName];
  }
  
  public function connectMysql(){
      if (!is_resource($this-&gt;mysql)){
          $this-&gt;mysql = mysql_connect($this-&gt;dbConfig-&gt;host, $this-&gt;dbConfig-&gt;username, $this-&gt;dbConfig-&gt;password, true);
          if (!$this-&gt;mysql){
              return false;
          }
          if (mysql_select_db($this-&gt;dbConfig-&gt;name, $this-&gt;mysql)){
              return $this-&gt;mysql;
          }
          else{
              mysql_close($this-&gt;mysql);
              $this-&gt;mysql = null;
              return false;
          }
      }
      return $this-&gt;mysql;
  }
  </code></pre>
  
  <p>}</p>