private function formatWhere($where, $operator = 'AND')
    {
        if (is_string($where)) {
            return $where;
        }

        $fullWhere = [];

        if (is_array($where)) {
            foreach ($where as $key => $value) {
                $fullWhere[] = sprintf(
                    '%s = %s',
                    $this->quoteIdentifier($key),
                    $this->quote($value)
                );
            }
        } elseif (is_a($where, 'Database\Query\Where')) {
            $operator = $where->getOperator();
            $whereClause = $where->getWhereClause();

            if (!empty($whereClause)) {
                foreach ($whereClause as $part) {
                    if ($part[0] === '=') {
                        $fullWhere[] = $this->formatWhere($part[1], $operator);
                    } else {
                        $q = sprintf(
                            '%s %s',
                            $this->quoteIdentifier($part[1]),
                            $part[0]
                        );

                        if (isset($part[2])) {
                            $q .= ' ' . $this->quote($part[2]);
                        }

                        $fullWhere[] = $q;
                    }
                }
            }
        }

        return '(' . implode(" {$operator} ", $fullWhere) . ')';
    }
private function formatWhere($where, $operator = 'AND')
    {
        if (is_string($where)) {
            return $where;
        }

        $fullWhere = [];

        if (is_array($where)) {
            foreach ($where as $key => $value) {
                $fullWhere[] = sprintf(
                    '%s = %s',
                    $this->quoteIdentifier($key),
                    $this->quote($value)
                );
            }
        } elseif (is_a($where, 'Database\Query\Where')) {
            $operator = $where->getOperator();
            $whereClause = $where->getWhereClause();

            if (!empty($whereClause)) {
                foreach ($whereClause as $part) {
                    if ($part[0] === '=') {
                        $fullWhere[] = $this->formatWhere($part[1], $operator);
                    } else {
                        $q = sprintf(
                            '%s %s',
                            $this->quoteIdentifier($part[1]),
                            $part[0]
                        );

                        if (isset($part[2])) {
                            $q .= ' ' . $this->quote($part[2]);
                        }

                        $fullWhere[] = $q;
                    }
                }
            }
        }

        return '(' . implode(" {$operator} ", $fullWhere) . ')';
    }
private function formatWhere ( $ where , $ operator = 'AND' ) { if ( is_string ( $ where ) ) { return $ where ; } $ fullWhere = [ ] ; if ( is_array ( $ where ) ) { foreach ( $ where as $ key => $ value ) { $ fullWhere [ ] = sprintf ( '%s = %s' , $ this -> quoteIdentifier ( $ key ) , $ this -> quote ( $ value ) ) ; } } elseif ( is_a ( $ where , 'Database\Query\Where' ) ) { $ operator = $ where -> getOperator ( ) ; $ whereClause = $ where -> getWhereClause ( ) ; if ( ! empty ( $ whereClause ) ) { foreach ( $ whereClause as $ part ) { if ( $ part [ 0 ] === '=' ) { $ fullWhere [ ] = $ this -> formatWhere ( $ part [ 1 ] , $ operator ) ; } else { $ q = sprintf ( '%s %s' , $ this -> quoteIdentifier ( $ part [ 1 ] ) , $ part [ 0 ] ) ; if ( isset ( $ part [ 2 ] ) ) { $ q .= ' ' . $ this -> quote ( $ part [ 2 ] ) ; } $ fullWhere [ ] = $ q ; } } } } return '(' . implode ( " {$operator} " , $ fullWhere ) . ')' ; }
Format the where clause of a MySQL query from a mixed range of types.
@param  $where
@param  string $operator
@return string
Format the where clause of a MySQL query from a mixed range of types .