Closed flopp26 closed 8 years ago
Did you try by hand if your request return a result ?
Try the code below in your controller.
private function datatable()
{
$dt = $this->get('datatable')
->setEntity("MyBundle:Task\Task", "x")// replace "XXXMyBundle:Entity" by your entity
->setDatatableId('dta-offres')
->setFields(
array(
"name" => 'x.name', // Declaration for fields:
"identifiant" => 'x.identifiant', // "label" => "alias.field_attribute_for_dql"
"_identifier_" => 'x.id') // you have to put the identifier field without label. Do not replace the "_identifier_"
)
->setWhere( // set your dql where statement
'x.error = :error',
array('error' => 0)
)
->setOrder("x.dateCreated", "desc"); // it's also possible to set the default order
// Print the SQL made by the DatatableBundle
var_dump($dt->getQueryBuilder()->getDoctrineQueryBuilder()->getQuery()->getSQL());
exit;
return $dt;
}
Thanks, I get not results because the clause setWhere do not replace value.
"SELECT t0_.name AS name_0, t0_.identifiant AS identifiant_1, t0_.id AS id_2 FROM task t0_ WHERE t0_.error = ? ORDER BY t0_.date_created DESC"
It's normal that the getSQL()
function return the request without replacing the value.
But did you try in an PhpMyAdmin interface, to execute the SQL with '0' replacing '?'
On my side I tried something similar, and it work well. So, I don't really see where come from this bug.
Yes it's not a bug :-) I'm silly, my colleague has redraw database... Sorry to have wasted your time...
That's Ok ;) Now, you know how to solve similar issue.
Hi,
Now it's works with symfony3, I get no results with my test.
the json is valid :
{"draw":1,"recordsTotal":"0","recordsFiltered":"0","data":[]}
If you have an idea why I get no results ;-)
thanks.
twig file is
My Controller:
My Entity