/**
  * Executes a select query on the DB
  * @param   mixed   $aql        aql | model name | aql array
  * @param   array   $clause     clause array | true (for $obj)
  * @param   mixed   $obj        Boolean or object name
  * @param   string  $statement  If passing in an aql array, use this to also pass in
  *                              the aql statement
  * @param   Boolean $force      Force master DB read
  * @param   mixed   $conn       Specific DB connection
  * @return  array
  * @global  $is_dev
  * @throws  \Sky\AQL\Exception  if model not found
  */
 public function select($aql, $clause = array(), $obj = false, $statement = null, $force = false, $conn = null)
 {
     global $is_dev;
     $conn = $conn ?: self::getDB();
     $silent = aql::in_transaction();
     if (!is_array($clause) && $clause === true) {
         $obj = true;
     }
     if (!$aql) {
         return array();
     }
     if (is_array($aql)) {
         $aql_array = $aql;
     } else {
         if (self::is_aql($aql)) {
             $statement = $aql;
             $aql_array = aql2array($statement);
         } else {
             $m = $aql;
             $statement = self::get_aql($m);
             if (!$statement) {
                 $e = new \Sky\AQL\Exception(' AQL Error: Model ' . $m . ' is not defined. ' . PHP_EOL . "path/to/models/{$m}/{$m}.aql is empty or not found.");
                 if (!$silent) {
                     self::$errors[] = $e;
                     return array();
                 }
                 throw $e;
             }
             $aql_array = aql2array::get($m, $statement);
         }
     }
     if ($obj && !is_bool($obj) && $m) {
         $obj = $m;
     }
     if (is_array($clause)) {
         $clause = self::check_clause_array($aql_array, $clause);
     }
     if ($_GET['aql_debug'] && $is_dev) {
         print_a($aql_array);
     }
     $returned = self::make_sql_array($aql_array, $clause);
     if ($_GET['aql_debug'] && $is_dev) {
         print_a($returned);
     }
     if ($_GET['refresh']) {
         $force = true;
     }
     $params = array('object' => $obj, 'aql_statement' => $statement, 'sub_do_set' => $force);
     return self::sql_result($returned, $params, $conn);
 }