mysql - PDO Mutiple Query execute and catch error -


i need execute 3 queries , find out query failed in pdo.

my config php

 $dbh = new pdo("mysql:host=$hostname;dbname=$dbname", $username, $password,array( pdo::attr_errmode => pdo::errmode_exception,pdo::attr_autocommit, false));   

my class file

 class myclass  {      function lastbench()      {  try {          $q1 = "select * user";         $code_pre = $dbh->prepare($q1);     $code_pre->execute();         if(!$code_pre)         {            throw new exception("no table called user");          }            $q2 = "select * userprofile";         $code_pre2 = $dbh->prepare($q2);     $code_pre2->execute();          if(!$code_pre2)         {            throw new exception("no profile table");          }       } catch ( exception $e)    {   $e->getmessage();      }      }      } 

any idea how specific block not executing..


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -