src/Sulu/Component/Rest/Listing/ListQueryBuilder.php
private function getWhere($prefix)
    {
        $result = '';
        // Only return where clause if there actually is some data
        if (count($this->where) > 0 || count($this->searchFields) > 0) {
            $wheres = [];
            $searches = [];

            $whereKeys = array_keys($this->where);

            // Get all fields which will appear in the where clause
            // The search fields already have the right format, and we have to use only the keys of where, because its
            // values contain the filter expression
            $fields = array_unique(array_merge($whereKeys, $this->searchFields));

            foreach ($fields as $key) {
                $keys = explode('_', $key);
                $prefixActual = $prefix;
                if (1 == count($keys)) {
                    $col = $keys[0];
                } else {
                    $i = count($keys);
                    $prefixActual = $keys[$i - 2];
                    $col = $keys[$i - 1];
                }
                // Add where clause y.z for x_y_z
                // FIXME DQL injection?
                if (in_array($key, $whereKeys)) {
                    $wheres[] = $prefixActual . '.' . $col . ' = ' . $this->where[$key];
                }
                if (in_array($key, $this->searchFields)) {
                    $comparator = '=';
                    $search = ':strictSearch';

                    // search by like
                    if (in_array($key, $this->searchTextFields)) {
                        $comparator = 'LIKE';
                        $search = ':search';
                    }
                    $searches[] = $prefixActual . '.' . $col . ' ' . $comparator . ' ' . $search;
                }
            }

            // concatenate the query
            if (!empty($wheres)) {
                $result .= implode(' AND ', $wheres);
            }

            if (!empty($searches)) {
                if ('' != $result) {
                    $result .= ' AND ';
                }
                $result .= '(' . implode(' OR ', $searches) . ')';
            }

            $result = 'WHERE ' . $result;
        }

        return $result;
    }
private function getWhere($prefix)
    {
        $result = '';
        // Only return where clause if there actually is some data
        if (count($this->where) > 0 || count($this->searchFields) > 0) {
            $wheres = [];
            $searches = [];

            $whereKeys = array_keys($this->where);

            // Get all fields which will appear in the where clause
            // The search fields already have the right format, and we have to use only the keys of where, because its
            // values contain the filter expression
            $fields = array_unique(array_merge($whereKeys, $this->searchFields));

            foreach ($fields as $key) {
                $keys = explode('_', $key);
                $prefixActual = $prefix;
                if (1 == count($keys)) {
                    $col = $keys[0];
                } else {
                    $i = count($keys);
                    $prefixActual = $keys[$i - 2];
                    $col = $keys[$i - 1];
                }
                // Add where clause y.z for x_y_z
                // FIXME DQL injection?
                if (in_array($key, $whereKeys)) {
                    $wheres[] = $prefixActual . '.' . $col . ' = ' . $this->where[$key];
                }
                if (in_array($key, $this->searchFields)) {
                    $comparator = '=';
                    $search = ':strictSearch';

                    // search by like
                    if (in_array($key, $this->searchTextFields)) {
                        $comparator = 'LIKE';
                        $search = ':search';
                    }
                    $searches[] = $prefixActual . '.' . $col . ' ' . $comparator . ' ' . $search;
                }
            }

            // concatenate the query
            if (!empty($wheres)) {
                $result .= implode(' AND ', $wheres);
            }

            if (!empty($searches)) {
                if ('' != $result) {
                    $result .= ' AND ';
                }
                $result .= '(' . implode(' OR ', $searches) . ')';
            }

            $result = 'WHERE ' . $result;
        }

        return $result;
    }
private function getWhere ( $ prefix ) { $ result = '' ; // Only return where clause if there actually is some data if ( count ( $ this -> where ) > 0 || count ( $ this -> searchFields ) > 0 ) { $ wheres = [ ] ; $ searches = [ ] ; $ whereKeys = array_keys ( $ this -> where ) ; // Get all fields which will appear in the where clause // The search fields already have the right format, and we have to use only the keys of where, because its // values contain the filter expression $ fields = array_unique ( array_merge ( $ whereKeys , $ this -> searchFields ) ) ; foreach ( $ fields as $ key ) { $ keys = explode ( '_' , $ key ) ; $ prefixActual = $ prefix ; if ( 1 == count ( $ keys ) ) { $ col = $ keys [ 0 ] ; } else { $ i = count ( $ keys ) ; $ prefixActual = $ keys [ $ i - 2 ] ; $ col = $ keys [ $ i - 1 ] ; } // Add where clause y.z for x_y_z // FIXME DQL injection? if ( in_array ( $ key , $ whereKeys ) ) { $ wheres [ ] = $ prefixActual . '.' . $ col . ' = ' . $ this -> where [ $ key ] ; } if ( in_array ( $ key , $ this -> searchFields ) ) { $ comparator = '=' ; $ search = ':strictSearch' ; // search by like if ( in_array ( $ key , $ this -> searchTextFields ) ) { $ comparator = 'LIKE' ; $ search = ':search' ; } $ searches [ ] = $ prefixActual . '.' . $ col . ' ' . $ comparator . ' ' . $ search ; } } // concatenate the query if ( ! empty ( $ wheres ) ) { $ result .= implode ( ' AND ' , $ wheres ) ; } if ( ! empty ( $ searches ) ) { if ( '' != $ result ) { $ result .= ' AND ' ; } $ result .= '(' . implode ( ' OR ' , $ searches ) . ')' ; } $ result = 'WHERE ' . $ result ; } return $ result ; }
Get DQL for Where clause.

@param string $prefix

@return string
Get DQL for Where clause .