public function buildSearchParameters()
    {
        $search_parameters = array();

        if ($this->isSearch) {
            // format for a search
            $approved_search = array();
            foreach ($this->getSearchFields() as $field => $value) {
                // if we spot a wild card, convert to LIKE
                if (strstr($value, '*')) {
                    $value = str_replace('*', '%', $value);
                    $approved_search[] = "$field LIKE '$value'";
                } else {
                    if (strstr($value, '!')) {
                        $value = str_replace('!', '%', $value);
                        $approved_search[] = "$field NOT LIKE '$value'";
                    } else {
                        $approved_search[] = "$field='$value'";
                    }
                }
            }
            // implode as specified by phalcon
            $search_parameters = array(
                implode(' and ', $approved_search)
            );
        }

        $limit = $this->getLimit();
        if ($limit) {
            $search_parameters['limit'] = $limit;
        }

        $offset = $this->getOffset();
        if ($offset) {
            $search_parameters['offset'] = $offset;
        }

        $sort = $this->getSort('sql');
        if ($sort) {
            // first_name,-last_name
            $search_parameters['order'] = $sort;
        }

        return $search_parameters;
    }