LanKit/DatatablesBundle — pull request #14 by waldo2188 (2013-04-18 10:09:36+00:00)
Title: A new way to count the number of rows

Instead of to recreate a querybuilder for count the number of row, why not just clone the actual QueryBuilder?

In the case where we use this kind of code :
```php
$datatable = $this->get('lankit_datatables')->getDatatable('WaldoMyBundle:Customer');

// Construction of DQL query
$datatable->makeSearch();

/* @var $queryBuilder \Doctrine\ORM\QueryBuilder */
$qb = $datatable->getQueryBuilder(); // we retrieve the QueryBuilder

// Here we add what we want in the query
// But I don't know why, it doesn't work really good if I use $qb->addSelect
$qb->select("Organisme.id, Organisme.sigle, Organisme.libelle, COUNT(ShoppingCart.id) as nbShoppingCart");
$qb->leftJoin("Customer.shoppingCart", "ShoppingCart")
->where(/* Lot of realy hard stuf */);

// We execute the query
$dataTableResult = $datatable->executeSearch();

// Add generate the response !
return $dataTableResult->getSearchResultsResponse();
```
When count of row is done the WHERE part isn't include. So we don't have the real number of row.

But if we just clone the QueryBuilder, it 's work fine (In my case).