/** explain query **/
 public function doExplainQuery()
 {
     $this->db = x("db");
     $this->collection = xn("collection");
     //field and sort
     $fields = xn("field");
     $orders = xn("order");
     $format = xn("format");
     if (empty($fields)) {
         $fields = array("_id", "", "", "");
         $orders = array("desc", "asc", "asc", "asc");
         x("field", $fields);
         x("order", $orders);
     }
     //conditions
     $native = xn("criteria");
     $criteria = $native;
     if (empty($criteria)) {
         $criteria = array();
         $native = "array(\n\t\n)";
     } else {
         $row = null;
         $eval = new VarEval($criteria, $format, $this->_mongo->selectDB($this->db));
         $row = $eval->execute();
         if (!is_array($row)) {
             $this->error = "To explain a query, criteria must be an array.";
             $this->display();
             return;
         }
         $criteria = $row;
     }
     x("criteria", $native);
     import("lib.mongo.RQuery");
     $query = new RQuery($this->_mongo, $this->db, $this->collection);
     $query->cond($criteria);
     //sort
     foreach ($fields as $index => $field) {
         if (!empty($field)) {
             if ($orders[$index] == "asc") {
                 $query->asc($field);
             } else {
                 $query->desc($field);
             }
         }
     }
     //command
     $command = x("command");
     if (!$command) {
         $command = "findAll";
         x("command", $command);
     }
     $queryHints = x("query_hints");
     if (!empty($queryHints)) {
         $db = $this->_mongo->selectDB($this->db);
         $indexes = $db->selectCollection($this->collection)->getIndexInfo();
         foreach ($indexes as $index) {
             if (in_array($index["name"], $queryHints)) {
                 $query->hint($index["key"]);
             }
         }
     }
     $cursor = $query->cursor();
     $this->ret = $this->_highlight($cursor->explain(), "json");
     $this->display();
 }