Dinamic values within a query
-
Hi!
Thank you for sharing all your knowledge contactashish13. I am facing some difficulties…
I am trying to run the following query through the admin panel:
SELECT station.name,
sum(CASE WHEN project_solution_state_date_2.state_id=1 THEN 1 END) AS state1,
sum(CASE WHEN project_solution_state_date_2.state_id=2 then 1 END) AS state2,
sum(CASE WHEN project_solution_state_date_2.state_id=3 THEN 1 END) AS state3,
sum(CASE WHEN project_solution_state_date_2.state_id=4 THEN 1 END) AS state4
FROM project_solution_state_date_2,station
WHERE project_solution_state_date_2.project_id = {DINAMIC VALUE} AND station.station_id = project_solution_state_date_2.station_id
GROUP BY project_solution_state_date_2.station_idHowever, I am not able to set the {DINAMIC VALUE}… I tried to use the snippet that you have facilitated in a previous post, but it does not work. This is what I am trying:
add_filter( ‘visualizer_db_query’, function( $query, $chart_id ) {
$query = str_replace( “LIMIT 1000”, “WHERE project_solution_state_date_2.project_id = ” . $DinamicValue . ” LIMIT 1000″, $query );
return $query;
}, 10, 2 );The variable $DinamicValue gets the value like this:
$DinamicValue = $_GET[‘course_id’];
Could you please tell me the way to proceed?
Thank you very much.
Best regards,
Nico
- The topic ‘Dinamic values within a query’ is closed to new replies.