protected function optionsToSQL(array $options)
 {
     // Check table (either options['from'] or me-self)
     $table = array_key_exists("from", $options) ? $options['from'] : $this->getFullyQualifiedName();
     // Create new SQL query
     $sql = new SQL($this->connection, $table);
     // Any table joins?
     if (array_key_exists("joins", $options)) {
         //
         //@TODO Join tables
         throw new Exception("Table JOINS not yet implemented.", 1);
     }
     // Select fields?
     if (array_key_exists("select", $options)) {
         // Apply select
         $sql->Select($options['select']);
     }
     // Conditions given?
     if (array_key_exists("conditions", $options)) {
         // Is it a field hash?
         if (ArrayUtil::IsHash($options['conditions'])) {
             // Do a where with the hash
             $sql->Where($options['conditions']);
         } else {
             // Is it a single string?
             if (is_string($options['conditions'])) {
                 // Wrap in array
                 $options['conditions'] = array($options['conditions']);
             }
             // Do a where with the string(s) as arguments
             call_user_func_array(array($sql, "Where"), $options['conditions']);
         }
     }
     // Order.
     if (array_key_exists("order", $options)) {
         $sql->Order($options['order']);
     }
     // Limit
     if (array_key_exists("limit", $options)) {
         $sql->Limit($options['limit']);
     }
     // Offset
     if (array_key_exists("offset", $options)) {
         $sql->Offset($options['offset']);
     }
     // Grouping
     if (array_key_exists("group", $options)) {
         $sql->Group($options['group']);
     }
     // Having
     if (array_key_exists("having", $options)) {
         $sql->Having($options['having']);
     }
     // Done
     return $sql;
 }