title: Fat Free: Using complex SQL queries
body: <p>Question: Is there an easier /safer way of running more complex SQL queries in Fat Free Framework. The solution I have is to use PDO, but it's messy and ugly as I can't throw exceptions easily.</p>
  
  <p>Background:</p>
  
  <p>Fat Free provides the AXON class for "safe" manipulation of databases, but I want to do a more complex query that AXON can handle.</p>
  
  <p>The DB class is exposed, but I would need to resort to "mysql_real_escape_string()" to build queries which is not guaranteed safe. So the solution appear to be using the exposed PDO.</p>
  
  <p>The exposed PDO as default error handling, which is a pain and results in ugly code.</p>
  
  <pre><code>        $pdo = F3::get('DB')-&gt;pdo;
          $sql = 'INSERT INTO config(config_name, config_value, comments) VALUES( :config_name , :config_value , :config_comments)
                       ON DUPLICATE KEY UPDATE config_value= :config_value2';
          if (!$stmt = $pdo-&gt;prepare($sql)) {
              $errorInfo = $pdo-&gt;errorInfo();
              trigger_error('PDO Error: ' . $pdo-&gt;errorCode(). ' ' . $errorInfo[2]);
              exit();
          }
  
          $stmt-&gt;bindValue(':config_name', $field, PDO::PARAM_STR);
          $stmt-&gt;bindValue(':config_value', $value, PDO::PARAM_STR);
          $stmt-&gt;bindValue(':config_comments', $comments, PDO::PARAM_STR);
          $stmt-&gt;bindValue(':config_value2', $value, PDO::PARAM_STR);
          if ($stmt-&gt;execute() === false) {
              $errorInfo = $stmt-&gt;errorInfo();
              trigger_error('PDO Error: ' . $stmt-&gt;errorCode(). ' ' . $errorInfo[2]);
              exit();
          }
  </code></pre>
  
  <p>So is there something neater that I'm missing? Or can AXON handle more complex queries?</p>