Ejemplo n.º 1
0
 function getExpressionTree($expr)
 {
     global $g_sqlSingleRecFuncs;
     $parser = new SqlParser($expr);
     $king_expr = new Expression();
     $current_expr =& $king_expr;
     while (!is_empty_str($elem = $parser->parseNextElementRaw())) {
         // function or IN / NOT IN?
         if (in_array(strtoupper($elem), $g_sqlSingleRecFuncs) || strtoupper($elem) == "IN" || strtoupper($elem) == "NOT IN") {
             $current_expr->expr_str .= $elem . " ";
             $elem = $parser->parseNextElementRaw();
             if ($elem != "(") {
                 print_error_msg("( expected after " . $current_expr->expr_str);
                 return null;
             }
             $current_expr->expr_str .= $elem;
             while (!is_empty_str($elem = $parser->parseNextElementRaw()) && $elem != ")") {
                 $current_expr->expr_str .= $elem;
             }
             $current_expr->expr_str .= $elem . " ";
             continue;
         }
         if ($elem == "(") {
             $current_expr->expr_str .= " % ";
             unset($new_expr);
             $new_expr = new Expression("");
             $current_expr->addChild($new_expr);
             $new_expr->setParent($current_expr);
             unset($current_expr);
             $current_expr =& $new_expr;
         } else {
             if ($elem == ")") {
                 unset($tmp);
                 $tmp =& $current_expr->getParent();
                 unset($current_expr);
                 $current_expr =& $tmp;
             } else {
                 // no spaces on .'s
                 if ($elem == ".") {
                     remove_last_char($current_expr->expr_str);
                     $current_expr->expr_str .= $elem;
                 } else {
                     $current_expr->expr_str .= $elem . " ";
                 }
             }
         }
     }
     return $king_expr;
 }
Ejemplo n.º 2
0
 function generateAdditionalColumnsFromWhereExpr($where_expr)
 {
     global $g_sqlSingleRecFuncs;
     $parser = new SqlParser($where_expr);
     $elem = "";
     $colFuncs = array();
     $colNames = array();
     $colTables = array();
     $index = -1;
     while (!is_empty_str($elem = $parser->parseNextElementRaw())) {
         // function  ?
         if (in_array(strtoupper($elem), $g_sqlSingleRecFuncs)) {
             ++$index;
             $colNames[$index] = "";
             $colTables[$index] = "";
             $colFuncs[$index] = strtoupper($elem);
             $elem = $parser->parseNextElementRaw();
             if ($elem != "(") {
                 print_error_msg("( expected after {$elem}");
                 return false;
             }
             while (!is_empty_str($elem = $parser->parseNextElementRaw()) && $elem != ")") {
                 if ($elem == ".") {
                     $colTables[$index] = $colNames[$index];
                     $colNames[$index] = $parser->parseNextElementRaw();
                 } else {
                     $colNames[$index] = $elem;
                 }
             }
         }
     }
     return $this->generateAdditionalColumnsFromArrays($colNames, $colTables, $colFuncs);
 }