Example #1
0
 /**
  * Returns the class maps involved in the query
  * @return array
  */
 public function getClassMaps()
 {
     return $this->b->getRootClassMaps();
 }
Example #2
0
 /**
  * Parse the EZOQL statement and translate it into equivalent 
  * SQL statement
  * 
  * @param string $q (the EZOQL query string)
  * @param array $args arguments for the query
  * @return false|string
  * @throws epExceptionQuery, epQueryExceptionBuilder
  */
 public function parse($oql_stmt, $args = array())
 {
     // reset aggregation function
     $this->aggr_func = false;
     // get oql statement (query)
     if ($oql_stmt) {
         $this->oq_stmt = $oql_stmt;
     }
     // check if query empty
     if (!$this->oq_stmt) {
         throw new epExceptionQuery('Empty EZOQL query');
         return false;
     }
     // get oql statement (query)
     if ($args) {
         $this->args = $args;
     }
     // instantiate a query parser
     if (!($p = new epQueryParser($oql_stmt))) {
         return false;
     }
     // parse query and get syntax tree
     $root = $p->parse();
     // check if there is any errors
     if (!$root || ($errors = $p->errors())) {
         $emsg = 'EZOQL parsing error';
         if ($errors) {
             $emsg .= ":\n";
             foreach ($errors as $error) {
                 $emsg .= $error->__toString() . "\n";
             }
         } else {
             $emsg .= " (unknown)";
         }
         throw new epExceptionQuery($emsg);
         return false;
     }
     // instantiate builder to build the SQL query
     if (!($b = new epQueryBuilder($root, $this->oq_stmt, $this->args))) {
         return false;
     }
     // build the SQL query from syntax tree
     $this->sql_stmt = $b->build();
     // get the aggregate function in the query
     $this->aggr_func = $b->getAggregateFunction();
     // get the limit
     $this->limit = $b->getLimit();
     // get the order
     $this->orderby = $b->getOrderBy();
     // get the root classes of this query
     $this->root_cms =& $b->getRootClassMaps();
     return $this->sql_stmt;
 }