Backend\Modules\Profiles\Actions\Groups::buildQuery PHP 메소드

buildQuery() 개인적인 메소드

Builds the query for this datagrid.
private buildQuery ( ) : array
리턴 array An array with two arguments containing the query and its parameters.
    private function buildQuery()
    {
        $parameters = array();
        /*
         * Start query, as you can see this query is build in the wrong place, because of the
         * filter it is a special case wherein we allow the query to be in the actionfile itself
         */
        $query = 'SELECT pg.id, pg.name, COUNT(gr.id) AS members_count
             FROM profiles_groups AS pg
             LEFT OUTER JOIN profiles_groups_rights AS gr ON gr.group_id = pg.id AND
                (gr.expires_on IS NULL OR gr.expires_on > NOW())
             GROUP BY pg.id
             HAVING 1';
        // add name
        if ($this->filter['name'] !== null) {
            $query .= ' AND pg.name LIKE ?';
            $parameters[] = '%' . $this->filter['name'] . '%';
        }
        // query
        return array($query, $parameters);
    }