Comment 2 for bug 934104

Revision history for this message
Adrian Liechti (jahweh) wrote :

Change the query-method in the pagination-class:

public function query($sql)
{
 // Get all parameters.
 $params = func_get_args();
  //array_shift($params); // first parameter of this function is query.
 /**
  * @author Adrian Liechti
  * To make it Possible to give the Query-Method an Array.
  */
 if (is_array($params[1])) {
  $paramArray = $params[1];
  array_unshift($paramArray, $params[0]);
  $params = $paramArray;
 }

 $this->searchFilter();
 return $this->finalQuery($params);
}

But there are more problems with the pagination! The parameters are not used, because the pagination should extend the PHPDS_query-class but it doesn't extend it.

My workaround looks like this:

public function invoke($parameters = null)
 {
  $pagination = $this->factory('pagination');

  $this->extraBuild($parameters);
  if (!empty($this->where)) {
   $this->sql .= "\n".'WHERE '.$this->where;
  }
  if (!empty($this->groupby)) {
   $this->sql .= "\n".'GROUP BY '.$this->groupby;
  }

  $get_results = $pagination->query($this->sql, $parameters);
//.........

But with this workaround you have to remove the search-function, because the pagination cannot handle the WHERE and GROUP BY etc. separately.