PHP | Problem -
#############1#################
$resultSet = DataObject::get(
$callerClass = 'Prospekt',
$filter = $dofilter,
$sort = 'date_to',
$join = '',
$limit = $limit
);
##################2###########
$sqlQuery = new SQLQuery();
$sqlQuery->select = array("Prospekt.ID,Prospekt.Document_id, Prospekt.InfoText,Market.URLSegment");
$sqlQuery->from = array("Prospekt
Left Join Market on Market.ID=Prospekt.MarketID");
$sqlQuery->where = array($dofilter);
$sqlQuery->orderby('date_to');
$sqlQuery->limit($limit);
$result2 = $sqlQuery->execute();
21/03/2012 4:09pm
PHP | Solution - Fred
function GNCurrentPage($length = 10) {
if (!isset($_GET['start']) || !is_numeric($_GET['start']) || (int) $_GET['start'] < 1) {
$_GET['start'] = 0;
}
return $this->gn->getResultsPage($_GET['start'], $length);
}
21/03/2012 4:06pm
PHP | Solution - Fred
Here is an older implementation I did that uses a SQLQuery execute() call.
protected function doSearchGNQuery() {
$q = singleton($this->guided_class)->GNBaseQuery();
list($database_params, $functional_params) = $this->dbAndFunctionalParams();
$facet_filters = $this->facetFilters($database_params);
foreach ($facet_filters as $key => $value) {
# Treat MenuTitle like SiteTree does (MenuTitle if set, else Title)
if (preg_match('/MenuTitle/', $key)) {
$title_key = preg_replace('/MenuTitle/', 'Title', $key);
$q->where("$key = '$value' OR $title_key = '$value'");
}
else {
$q->where($key, $value);
}
}
$result = $q->execute();
$result = singleton($this->guided_class)->buildDataObjectSet($result);
$this->results = $result;
}
function getResults() {
return $this->results;
}
function getResultsPage($start, $length) {
return $this->results->getRange($start, $length);
}
21/03/2012 4:02pm
PHP | Solution - Fred
This is a very minimalist example, because all the work is done in SearchContext. I'm looking for a bigger example.
/**
* Build the template control for Results
*
* @return DataObjectSet List of results
*/
function getResults() {
return $this->search_context->getResults($this->facetFilters($this->facetParams()));
}
/**
* Return a slice of results for one page
*
* @param type $start
* @param type $length
* @return DataObjectSet Slice of results
*/
function getResultsPage($start, $length) {
return $this->getResults()->getRange($start, $length);
}
21/03/2012 3:44pm
PHP | Solution - Anonymous
$dospr = new DataObjectSet();
if( $result2->numRecords() > 0 ) foreach( $result2 as $row ){
$dospr->push( new ArrayData($row) );
}
Here's the code that drives the pagination