Example #1
0
 public function buildCond($whereParam, $sob, $phValues, $first = null)
 {
     if ($first === null) {
         $first = true;
     }
     $sb = new StringBuf();
     $where = _hx_explode(",", $whereParam);
     if ($where->length === 0) {
         return false;
     }
     $_g = 0;
     while ($_g < $where->length) {
         $w = $where[$_g];
         ++$_g;
         $wData = _hx_string_call($w, "split", array("|"));
         $values = $wData->slice(2, null);
         $filter_tables = null;
         if (Util::any2bool($this->param) && $this->param->exists("filter_tables") && Util::any2bool($this->param->get("filter_tables"))) {
             $jt = $this->param->get("filter_tables");
             $filter_tables = _hx_explode(",", $jt);
             unset($jt);
         }
         haxe_Log::trace(Std::string($wData) . ":" . _hx_string_or_null($this->joinTable) . ":" . Std::string($filter_tables), _hx_anonymous(array("fileName" => "Model.hx", "lineNumber" => 386, "className" => "Model", "methodName" => "buildCond")));
         if (_hx_deref(new EReg("^pay_[a-zA-Z_]+\\.", ""))->match($wData[0]) && _hx_array_get(_hx_explode(".", $wData[0]), 0) !== $this->joinTable) {
             continue;
         }
         if ($first) {
             $sb->add(" WHERE ");
         } else {
             $sb->add(" AND ");
         }
         $first = false;
         $_g1 = strtoupper($wData[1]);
         switch ($_g1) {
             case "BETWEEN":
                 if (!($values->length === 2) && Lambda::hforeach($values, array(new _hx_lambda(array(&$_g, &$_g1, &$filter_tables, &$first, &$phValues, &$sb, &$sob, &$values, &$w, &$wData, &$where, &$whereParam), "Model_13"), 'execute'))) {
                     S::hexit("BETWEEN needs 2 values - got only:" . _hx_string_or_null($values->join(",")));
                 }
                 $sb->add($this->quoteField($wData[0]));
                 $sb->add(" BETWEEN ? AND ?");
                 $phValues->push(new _hx_array(array($wData[0], $values[0])));
                 $phValues->push(new _hx_array(array($wData[0], $values[1])));
                 break;
             case "IN":
                 $sb->add($this->quoteField($wData[0]));
                 $sb->add(" IN(");
                 $sb->add($values->map(array(new _hx_lambda(array(&$_g, &$_g1, &$filter_tables, &$first, &$phValues, &$sb, &$sob, &$values, &$w, &$wData, &$where, &$whereParam), "Model_14"), 'execute'))->join(","));
                 $sb->add(")");
                 break;
             case "LIKE":
                 $sb->add($this->quoteField($wData[0]));
                 $sb->add(" LIKE ?");
                 $phValues->push(new _hx_array(array($wData[0], $wData[2])));
                 break;
             default:
                 $sb->add($this->quoteField($wData[0]));
                 if (_hx_deref(new EReg("^(<|>)", ""))->match($wData[1])) {
                     $eR = new EReg("^(<|>)", "");
                     $eR->match($wData[1]);
                     $val = Std::parseFloat($eR->matchedRight());
                     $sb->add(_hx_string_or_null($eR->matched(0)) . "?");
                     $phValues->push(new _hx_array(array($wData[0], $val)));
                     continue 2;
                 }
                 if ($wData[1] === "NULL") {
                     $sb->add(" IS NULL");
                 } else {
                     $sb->add(" = ?");
                     $phValues->push(new _hx_array(array($wData[0], $wData[1])));
                 }
                 break;
         }
         unset($_g1);
         unset($wData, $w, $values, $filter_tables);
     }
     $sob->add($sb->b);
     return true;
 }