public function build($count = false)
    {
        $modelNameSpace = $this->model->getModelNameSpace();
        $mm = $this->getDI()->get('modelsManager');
        $query = $mm->createBuilder()->from($modelNameSpace);

        // $columns = $this->model->getAllowedColumns(true);
        $columns = array(
            "$modelNameSpace.*"
        );

        // process hasOne Joins
        $this->queryJoinHelper($query);
        $this->querySearchHelper($query);
        $this->querySortHelper($query);

        if ($count) {
            $query->columns('count(*) as count');
        } else {
            // preserve any columns added through joins
            $existingColumns = $query->getColumns();
            $allColumns = array_merge($columns, $existingColumns);
            $query->columns($allColumns);
        }
        // skip limit if returning a count
        if (!$count) {
            $this->queryLimitHelper($query);
        }

        // todo build fields feature into PHQL instead of doing in PHP
        return $query;
    }
public function build($count = false)
    {
        $modelNameSpace = $this->model->getModelNameSpace();
        $mm = $this->getDI()->get('modelsManager');
        $query = $mm->createBuilder()->from($modelNameSpace);

        // $columns = $this->model->getAllowedColumns(true);
        $columns = array(
            "$modelNameSpace.*"
        );

        // process hasOne Joins
        $this->queryJoinHelper($query);
        $this->querySearchHelper($query);
        $this->querySortHelper($query);

        if ($count) {
            $query->columns('count(*) as count');
        } else {
            // preserve any columns added through joins
            $existingColumns = $query->getColumns();
            $allColumns = array_merge($columns, $existingColumns);
            $query->columns($allColumns);
        }
        // skip limit if returning a count
        if (!$count) {
            $this->queryLimitHelper($query);
        }

        // todo build fields feature into PHQL instead of doing in PHP
        return $query;
    }
public function build ( $ count = false ) { $ modelNameSpace = $ this -> model -> getModelNameSpace ( ) ; $ mm = $ this -> getDI ( ) -> get ( 'modelsManager' ) ; $ query = $ mm -> createBuilder ( ) -> from ( $ modelNameSpace ) ; // $columns = $this->model->getAllowedColumns(true); $ columns = array ( "$modelNameSpace.*" ) ; // process hasOne Joins $ this -> queryJoinHelper ( $ query ) ; $ this -> querySearchHelper ( $ query ) ; $ this -> querySortHelper ( $ query ) ; if ( $ count ) { $ query -> columns ( 'count(*) as count' ) ; } else { // preserve any columns added through joins $ existingColumns = $ query -> getColumns ( ) ; $ allColumns = array_merge ( $ columns , $ existingColumns ) ; $ query -> columns ( $ allColumns ) ; } // skip limit if returning a count if ( ! $ count ) { $ this -> queryLimitHelper ( $ query ) ; } // todo build fields feature into PHQL instead of doing in PHP return $ query ; }
build a PHQL based query to be executed by the runSearch method
broken up into helpers so extending this function duplicates less code

@param boolean $count should we only gather a count of the query?
@return mixed
@throws HTTPException
build a PHQL based query to be executed by the runSearch method broken up into helpers so extending this function duplicates less code