Reputation: 3690
I have this code that uses a raw SQL query inside my controller:
$sql1 = "SELECT completion_date FROM enviro_figures_upload GROUP BY YEAR(completion_date), MONTH(completion_date) DESC;";
$activeDate = $this->getDoctrine()->getManager()->getConnection()->prepare($sql1);
$activeDate->execute();
$activeDate->fetchAll();
This code then passes the data to the view which is then used in a drop down date picker. However, no results are passed to the view even though running that SQL query on the database returns the results I need. What am I missing in order to pass this data to the view?
Upvotes: 0
Views: 461
Reputation: 4210
$activeDate->execute(); $activeDate->fetchAll(); This code then passes the data to the view ...
this code doesn't pass the data to view, you have to pass the data to view by array option in render
method..
something like this:
$sql1 = "SELECT completion_date FROM enviro_figures_upload GROUP BY YEAR(completion_date), MONTH(completion_date) DESC;";
$activeDate = $this->getDoctrine()->getManager()->getConnection()->prepare($sql1);
$activeDate->execute();
$result = $activeDate->fetchAll();
return $this->render('TEMPLATE_PATH', [
'result' => $result
]);
Upvotes: 2