public function where($where, &$params)
    {
        if (!is_array($where)) {
            throw new \Exception("Invalid where clause specified, must be an array");
        }

        $params = Helper::toArray($params);

        $query = "";

        $andFlag = false;

        foreach ($where as $field => $value) {

            # Add the and flag if this isn't the first field
            if ($andFlag) {
                $query .= "AND ";
            } else {
                $andFlag = true;
            }

            # Add the field name to the query
            $query .= $this->quoteField($field);

            # Convert arrays to use the in helper
            if (is_array($value)) {
                $helperMap = [
                    "<"     =>  "lessThan",
                    "<="    =>  "lessThanOrEqualTo",
                    ">"     =>  "greaterThan",
                    ">="    =>  "greaterThanOrEqualTo",
                    "="     =>  "equals",
                    "<>"    =>  "notEqualTo",
                ];
                $clause = (string) reset($value);
                if (count($value) === 2 && isset($helperMap[$clause])) {
                    $method = $helperMap[$clause];
                    $val = next($value);
                    trigger_error("Using arrays for complex where clauses is deprecated in favour of the helper methods, eg Sql::" . $method . "(" . $val . ")", E_USER_DEPRECATED);
                    $value = static::$method($val);
                } else {
                    $value = static::in($value);
                }
            }

            # Any parameters not using a helper should use the standard equals helper
            if (!is_object($value)) {
                $value = static::equals($value);
            }

            $query .= " " . $value->getClause() . " ";
            foreach ($value->getValues() as $val) {
                $params[] = $val;
            }
        }

        return $query;
    }
public function where($where, &$params)
    {
        if (!is_array($where)) {
            throw new \Exception("Invalid where clause specified, must be an array");
        }

        $params = Helper::toArray($params);

        $query = "";

        $andFlag = false;

        foreach ($where as $field => $value) {

            # Add the and flag if this isn't the first field
            if ($andFlag) {
                $query .= "AND ";
            } else {
                $andFlag = true;
            }

            # Add the field name to the query
            $query .= $this->quoteField($field);

            # Convert arrays to use the in helper
            if (is_array($value)) {
                $helperMap = [
                    "<"     =>  "lessThan",
                    "<="    =>  "lessThanOrEqualTo",
                    ">"     =>  "greaterThan",
                    ">="    =>  "greaterThanOrEqualTo",
                    "="     =>  "equals",
                    "<>"    =>  "notEqualTo",
                ];
                $clause = (string) reset($value);
                if (count($value) === 2 && isset($helperMap[$clause])) {
                    $method = $helperMap[$clause];
                    $val = next($value);
                    trigger_error("Using arrays for complex where clauses is deprecated in favour of the helper methods, eg Sql::" . $method . "(" . $val . ")", E_USER_DEPRECATED);
                    $value = static::$method($val);
                } else {
                    $value = static::in($value);
                }
            }

            # Any parameters not using a helper should use the standard equals helper
            if (!is_object($value)) {
                $value = static::equals($value);
            }

            $query .= " " . $value->getClause() . " ";
            foreach ($value->getValues() as $val) {
                $params[] = $val;
            }
        }

        return $query;
    }
public function where ( $ where , & $ params ) { if ( ! is_array ( $ where ) ) { throw new \ Exception ( "Invalid where clause specified, must be an array" ) ; } $ params = Helper :: toArray ( $ params ) ; $ query = "" ; $ andFlag = false ; foreach ( $ where as $ field => $ value ) { # Add the and flag if this isn't the first field if ( $ andFlag ) { $ query .= "AND " ; } else { $ andFlag = true ; } # Add the field name to the query $ query .= $ this -> quoteField ( $ field ) ; # Convert arrays to use the in helper if ( is_array ( $ value ) ) { $ helperMap = [ "<" => "lessThan" , "<=" => "lessThanOrEqualTo" , ">" => "greaterThan" , ">=" => "greaterThanOrEqualTo" , "=" => "equals" , "<>" => "notEqualTo" , ] ; $ clause = ( string ) reset ( $ value ) ; if ( count ( $ value ) === 2 && isset ( $ helperMap [ $ clause ] ) ) { $ method = $ helperMap [ $ clause ] ; $ val = next ( $ value ) ; trigger_error ( "Using arrays for complex where clauses is deprecated in favour of the helper methods, eg Sql::" . $ method . "(" . $ val . ")" , E_USER_DEPRECATED ) ; $ value = static :: $ method ( $ val ) ; } else { $ value = static :: in ( $ value ) ; } } # Any parameters not using a helper should use the standard equals helper if ( ! is_object ( $ value ) ) { $ value = static :: equals ( $ value ) ; } $ query .= " " . $ value -> getClause ( ) . " " ; foreach ( $ value -> getValues ( ) as $ val ) { $ params [ ] = $ val ; } } return $ query ; }
Convert an array of parameters into a valid where clause
Convert an array of parameters into a valid where clause