Example #1
0
 /**
  * 拼接单条的高级查询SQL
  * @param conditionSql 条件SQL
  * @param leftParentheses 左括号 0-( 1-(( 2-((( 3-(((( 4-(((((
  * @param field 字段信息
  * @param condition 条件 0-= 1-!= 2-like 3-start with 4-end with 5-> 6->= 7-< 8-<= 9-is null 10-is not null
  * @param value 值
  * @param rightParentheses 右括号 0-) 1-)) 2-))) 3-)))) 4-)))))
  * @param logic 逻辑符号 0-and 1-or
  */
 static function getSingleAdvanceQueryConditionSql($leftParentheses, $field, $condition, $value, $rightParentheses, $logic, &$args)
 {
     $conditionSql = "";
     //		获取左括号内容、右括号内容、逻辑符号内容
     $logic = QueryUtils::getConditionLogicContent($logic);
     //		根据条件类型拼接SQL
     $conditionSql .= " " . $leftParentheses . " ";
     if ($condition === "0") {
         $conditionSql .= " " . $field . " = ? ";
         array_push($args, $value);
     } else {
         if ($condition === "1") {
             $conditionSql .= " " . $field . " != ? ";
             array_push($args, $value);
         } else {
             if ($condition === "2") {
                 $conditionSql .= " " . $field . " like ? ";
                 array_push($args, "%" . $value . "%");
             } else {
                 if ($condition === "3") {
                     $conditionSql .= " " . $field . " like ? ";
                     array_push($args, $value . "%");
                 } else {
                     if ($condition === "4") {
                         $conditionSql .= " " . $field . " like ? ";
                         array_push($args, "%" . $value);
                     } else {
                         if ($condition === "5") {
                             $conditionSql .= " " . $field . " > ? ";
                             array_push($args, $value);
                         } else {
                             if ($condition === "6") {
                                 $conditionSql .= " " . $field . " >= ? ";
                                 array_push($args, $value);
                             } else {
                                 if ($condition === "7") {
                                     $conditionSql .= " " . $field . " < ? ";
                                     array_push($args, $value);
                                 } else {
                                     if ($condition === "8") {
                                         $conditionSql .= " " . $field . " <= ? ";
                                         array_push($args, $value);
                                     } else {
                                         if ($condition === "9") {
                                             $conditionSql .= " " . $field . " is null ";
                                         } else {
                                             if ($condition === "10") {
                                                 $conditionSql .= " " . $field . " is not null ";
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $conditionSql .= " " . $rightParentheses . " ";
     $conditionSql .= " " . $logic . " ";
     return $conditionSql;
 }