예제 #1
0
 public function orongoquery($query = null)
 {
     terminalAuth();
     if ($query == null) {
         throw new Exception("No query string.");
     }
     $query = new OrongoQuery($query);
     $result = OrongoQueryHandler::exec($query);
     $return = array();
     $qa = $query->getQueryArray();
     if ($qa["action"] == "count") {
         return $result;
     } else {
         $str = "";
         for ($i = 0; $i < count($result) - 1; $i++) {
             $obj = $result[$i];
             if ($obj instanceof Article) {
                 $arr = array($i . "_" . "article title" => $obj->getTitle(), $i . "_" . "article id" => $obj->getID(), $i . "_" . "article author name" => $obj->getAuthorName(), $i . "_" . "article author id" => $obj->getAuthorID(), $i . "_" . "article date" => $obj->getDate(), $i . "_" . "article comments count" => $obj->getCommentCount());
                 $return = array_merge($arr, $return);
             } elseif ($obj instanceof Comment) {
                 $arr = array($i . "_" . "comment id" => $obj->getID(), $i . "_" . "comment author name" => $obj->getAuthorName(), $i . "_" . "comment author id" => $obj->getAuthorID(), $i . "_" . "comment timestamp" => $obj->getTimestamp());
                 $return = array_merge($arr, $return);
             } elseif ($obj instanceof Page) {
                 $arr = array($i . "_" . "page title" => $obj->getTitle(), $i . "_" . "page id" => $obj->getID());
                 $return = array_merge($arr, $return);
             } elseif ($obj instanceof User) {
                 $arr = array($i . "_" . "user name" => $obj->getName(), $i . "_" . "user id" => $obj->getID(), $i . "_" . "user rank" => $obj->getRank(), $i . "_" . "user email" => $obj->getEmail());
                 $return = array_merge($arr, $return);
             }
         }
     }
     return $return;
 }
예제 #2
0
 public function __invoke($args)
 {
     if (count($args) < 1) {
         throw new OrongoScriptParseException("Arguments missing for OQ.Query()");
     }
     $query = new OrongoQuery($args[0]);
     $arr = $query->getQueryArray();
     $objs = array();
     if (isset($arr['action']) && $arr['action'] == 'count') {
         return new OrongoVariable(OrongoQueryHandler::exec($query));
     } else {
         $objs = OrongoQueryHandler::exec($query);
         foreach ($objs as &$obj) {
             $obj = $obj->getID();
         }
     }
     return new OrongoList($objs);
 }
예제 #3
0
/**
* Executes a query string [equivalent to OrongoQueryHandler::exec(new OrongoQuery(QUERY)); ]
* @param String $paramQuery query string
* @return array resultset
*/
function orongo_query($paramQuery)
{
    return OrongoQueryHandler::exec(new OrongoQuery($paramQuery));
}