src/Mysqli.php
public function where($where, $value = null, $exp = null)
    {

        $expRule[0] = ['>', '<', '>=', '<=', '!=', 'like', '<>'];
        $expRule[1] = ['in', 'not in', 'IN', 'NOT IN'];
        $expRule[2] = ['instr', 'INSTR'];
        $expRule[3] = ['between', 'BETWEEN'];
        $expRule[4] = ['or', 'OR'];

        if (!$where) {
            return $this;
        }

        $newWhere = '';

        if ($value !== null && $exp !== null) {
            $map[$where] = [$value, $exp];
            $where       = $map;
        } elseif ($value !== null && $exp === null) {
            $map[$where] = $value;
            $where       = $map;
        }

        if (is_array($where)) {
            foreach ($where as $mapField => $v) {

                $mapField = $this->addFieldTag($mapField);

                if (is_array($v)) {

                    list($mapExp, $mapValue) = $v;

                    if (in_array($mapExp, $expRule[0])) {
                        $newWhere .= $mapField . '  ' . $mapExp . ' \'' . $mapValue . '\' AND ';
                    } elseif (in_array($mapExp, $expRule[1])) {
                        if (!$mapValue) {
                            $newWhere .= $mapField . '  ' . $mapExp . ' (\'\') AND ';
                        } else {
                            if (!is_array($mapValue) && stripos($mapValue, ',') !== false) {
                                $mapValue = explode(',', $mapValue);
                            }
                            $mapValue      = is_array($mapValue) ? $mapValue : (array) $mapValue;
                            $commonInValue = '';
                            foreach ($mapValue as $inValue) {
                                $commonInValue .= '\'' . $inValue . '\',';
                            }
                            $commonInValue = substr($commonInValue, 0, -1);
                            $newWhere .= $mapField . '  ' . $mapExp . ' (' . $commonInValue . ') AND ';
                        }
                    } elseif (in_array($mapExp, $expRule[2])) {
                        $newWhere .= $mapExp . '(' . $mapField . ',\'' . $mapValue . '\') AND ';
                    } elseif (in_array($mapExp, $expRule[3])) {

                        $newWhere .= $mapField . '  ' . $mapExp . ' \'' . $mapValue . '\' AND \'' . $v[2] . '\' AND ';
                    } elseif (in_array($mapExp, $expRule[4])) {
                        $newWhere .= $mapField . ' = \'' . $mapValue . '\' OR ';
                    }
                } elseif ($mapField == '_string') {
                    $newWhere .= $v . ' AND ';
                } else {
                    $newWhere .= $mapField . ' = \'' . $v . '\' AND ';
                }
            }
        } else {
            $newWhere = $where;
        }

        if (stripos($this->where, 'WHERE') === false) {
            $this->where = ' WHERE ' . substr($newWhere, 0, -4);
        } else {
            $this->where .= ' AND ' . substr($newWhere, 0, -4);
        }

        $this->build['where'] = $where;
        return $this;
    }
public function where($where, $value = null, $exp = null)
    {

        $expRule[0] = ['>', '<', '>=', '<=', '!=', 'like', '<>'];
        $expRule[1] = ['in', 'not in', 'IN', 'NOT IN'];
        $expRule[2] = ['instr', 'INSTR'];
        $expRule[3] = ['between', 'BETWEEN'];
        $expRule[4] = ['or', 'OR'];

        if (!$where) {
            return $this;
        }

        $newWhere = '';

        if ($value !== null && $exp !== null) {
            $map[$where] = [$value, $exp];
            $where       = $map;
        } elseif ($value !== null && $exp === null) {
            $map[$where] = $value;
            $where       = $map;
        }

        if (is_array($where)) {
            foreach ($where as $mapField => $v) {

                $mapField = $this->addFieldTag($mapField);

                if (is_array($v)) {

                    list($mapExp, $mapValue) = $v;

                    if (in_array($mapExp, $expRule[0])) {
                        $newWhere .= $mapField . '  ' . $mapExp . ' \'' . $mapValue . '\' AND ';
                    } elseif (in_array($mapExp, $expRule[1])) {
                        if (!$mapValue) {
                            $newWhere .= $mapField . '  ' . $mapExp . ' (\'\') AND ';
                        } else {
                            if (!is_array($mapValue) && stripos($mapValue, ',') !== false) {
                                $mapValue = explode(',', $mapValue);
                            }
                            $mapValue      = is_array($mapValue) ? $mapValue : (array) $mapValue;
                            $commonInValue = '';
                            foreach ($mapValue as $inValue) {
                                $commonInValue .= '\'' . $inValue . '\',';
                            }
                            $commonInValue = substr($commonInValue, 0, -1);
                            $newWhere .= $mapField . '  ' . $mapExp . ' (' . $commonInValue . ') AND ';
                        }
                    } elseif (in_array($mapExp, $expRule[2])) {
                        $newWhere .= $mapExp . '(' . $mapField . ',\'' . $mapValue . '\') AND ';
                    } elseif (in_array($mapExp, $expRule[3])) {

                        $newWhere .= $mapField . '  ' . $mapExp . ' \'' . $mapValue . '\' AND \'' . $v[2] . '\' AND ';
                    } elseif (in_array($mapExp, $expRule[4])) {
                        $newWhere .= $mapField . ' = \'' . $mapValue . '\' OR ';
                    }
                } elseif ($mapField == '_string') {
                    $newWhere .= $v . ' AND ';
                } else {
                    $newWhere .= $mapField . ' = \'' . $v . '\' AND ';
                }
            }
        } else {
            $newWhere = $where;
        }

        if (stripos($this->where, 'WHERE') === false) {
            $this->where = ' WHERE ' . substr($newWhere, 0, -4);
        } else {
            $this->where .= ' AND ' . substr($newWhere, 0, -4);
        }

        $this->build['where'] = $where;
        return $this;
    }
查询条件
@date   2018-06-29T15:50:51+0800
@author ChenMingjiang
@param  [type]                   $where [description]
@param  [type]                   $value [description]
@param  [type]                   $exp   [description]
@return [type]                          [description]