title: PDO using MySql Case for ordering with bound variables
body: <p>I've been researching this and I think I've found the best solution but I'm not 100% sure. I have a good handle on PDO but this is the first time I've encountered CASE in mysql. This code is working but I'm wondering if it's efficient? If I were to have multiple keys, I would have to write many arrays to be able to search and order. Is there a shorter way to write this code or is this the most efficient? Thanks!</p>
  
  <pre><code>$filters = "
      AND (name LIKE :keys
      OR note LIKE :keys
      OR tagnum = :skeys)
  ";
  $order = "
      ORDER BY
          CASE
              WHEN tagnum = :skeys THEN 0
              WHEN name = :skeys THEN 1
              WHEN name LIKE :lkeys THEN 2
              WHEN name LIKE :rkeys THEN 3
              ELSE 4
          END
      ASC
  ";
  $arr[':keys'] = "%$keys%"; // both wild cards
  $arr[':skeys'] = $keys; // stripped keys, no wild cards
  $arr[':lkeys'] = "$keys%"; // left key, right wild card
  $arr[':rkeys'] = "%$keys"; // right key, left wild card
  </code></pre>