I just implement the jquery datatables 1.10 to phalcon available for downoad download. everything is working but i feel so stupid with the code below,
// i can't find
$builder->rowCount();
// and can't find
$builder->setFetchMode();
is there any alternative?
this is the code that i think so stupid:
/**
* @param \Phalcon\Mvc\Model\Query\BuilderInterface $builder
* @return mixed
*/
public function render($builder)
{
$from = $builder->getFrom();
$this->cols = array_values($builder->getColumns());
$this->render['recordsTotal'] = (int) $from::count([str_replace(['(', ')'],'',$builder->getWhere())]);
$this->setFiltering();
if($this->search['global'])
foreach ($this->search['global'] as $globalSearch) {
$builder->orWhere($globalSearch);
}
if($this->search['column'])
foreach ($this->search['column'] as $columnSearch) {
$builder->andWhere($columnSearch);
}
$this->render['recordsFiltered'] = (int) $from::count([str_replace(['(', ')'],'',$builder->getWhere()), 'bind' => $this->bound]);
$this->setPaging();
$builder->limit($this->paging);
$this->setOrdering();
if($this->ordering)
$builder->orderBy(join(',', $this->ordering));
$v = [];
foreach ($builder->getQuery()->execute($this->bound)->toArray() as $ar) {
$v[] = array_values($ar);
}
$this->render['data'] = $v;
return $this->render;
}
}
EDIT: github file
https://github.com/sumeko/phadable/blob/master/app/library/DataTables/Builder.php