title: How can create parameterized query with AND and Like operator using PDO?
body: <p>I'm trying to create query which can fetch data by title and category id. Below simple query is working for me in phpMyAdmin.</p>
  
  <pre><code>`SELECT * FROM `ws_promotion` AS prm LEFT JOIN `ws_pro_cat` AS prmCat ON prm.`pm_id` = prmCat.`pm_id` 
  WHERE prmCat.`cat_id` = 3 AND prm.`pm_title` LIKE '%Essa%' `
  </code></pre>
  
  <p>I'm using PDO, so I have to convert it according to PDO procedure. I'm trying below two queries but these are returning error.</p>
  
  <h2>PDO query 1</h2>
  
  <pre><code>    $PromotionSts=$this-&gt;pdoConnection-&gt;prepare("SELECT * FROM `ws_promotion` AS prm LEFT JOIN `ws_pro_cat` AS prmCat ON prm.`pm_id` = prmCat.`pm_id` 
                      WHERE prmCat.`cat_id` = :cat_id AND prm.`pm_title` LIKE ? ");
      $PromotionSts-&gt;bindParam(':cat_id', $cat_id);
      $PromotionSts-&gt;bindParam(':pm_title', '%$pm_title%');
      $cat_id = $cat_id;
      $pm_title = $pm_title;
      $PromotionSts-&gt;execute();
  </code></pre>
  
  <h2>PDO query 2</h2>
  
  <pre><code>$PromotionSts=$this-&gt;pdoConnection-&gt;prepare("SELECT * FROM `ws_promotion` AS prm LEFT JOIN `ws_pro_cat` AS prmCat ON prm.`pm_id` = prmCat.`pm_id` 
                  WHERE prmCat.`cat_id` = :cat_id AND prm.`pm_title` LIKE ? ");
  $PromotionSts-&gt;execute(array(3,'%Essa%'));
  </code></pre>
  
  <p>I will appreciate if someone guide me regarding this. Thank You</p>