/**
  * Prepares the specified statement if the $queries entry is not already a statement instance
  * @param string $name Name of the statement to prepare
  * @return bool
  */
 function prepareStatement($name, $params = array())
 {
     static $patterns = null;
     if (!@$this->queries[$name]) {
         trigger_error("Cannot execute unknown/invalid query {$name}", E_USER_WARNING);
         return false;
     }
     if (!is_object($this->queries[$name])) {
         if (!isset($patterns)) {
             $patterns = array();
             // Replace the real table names with their prefixed equivalent
             foreach ($this->tables as $k => $v) {
                 $patterns[] = '{' . $k . '}';
             }
         }
         $this->queries[$name] = $this->db->prepare(str_replace($patterns, $this->tables, $this->queries[$name]));
     }
     if (!empty($params)) {
         if (isset($this->parameters[$name])) {
             foreach ($params as $k => $v) {
                 $this->queries[$name]->bindValue(is_int($k) ? $k + 1 : $k, $v, $this->parameters[$name][$k]);
             }
         } else {
             foreach ($params as $k => $v) {
                 $this->queries[$name]->bindValue(is_int($k) ? $k + 1 : $k, $v);
             }
         }
     }
     return true;
 }