I'm testing the Gantt chart, but with multiple projects, but I have an issue which I'm battling with.
I'm using PHPMaker 2023.13 and the DB is PostgreSQL 13.
The Gantt is working just fine with a single project. So everything is working up that point.
I have added a dropdown selector, which I populate dynamically with the different projects. So this part is all good. I then have an event handler function that pick the selected value (from the dropdown) which I want to use to get the selected project data/detail. This is where I'm running into issues when I modify the query with a WHERE clause.
So the standard query for adding rows to the Gantt, as shown below is working fine:
data.addRows(<?= ExecuteJson("SELECT TaskID, TaskName, ResourceID, Start, End, Duration, PercentComplete, Dependencies FROM tasks", ["header" => false, "array" => true, "convertdate" => true]); ?>);
I have attempted the following:
SELECT TaskID, TaskName, ResourceID, Start, End, Duration, PercentComplete, Dependencies FROM tasks WHERE projectid = 'myvariable'
but then I get the following error: Undefined constant "PHPMaker2023\myproject\myvariable", however myvariable is declared and it contains the relevant projectid for the WHERE clause.
If I hard code the WHERE clause, it is working fine, i.e.:
SELECT TaskID, TaskName, ResourceID, Start, End, Duration, PercentComplete, Dependencies FROM tasks **WHERE projectid = 1**
I can change the WHERE projectid = ? to any other (valid) value, and it load that project perfectly. I just can't get the query to work with the variable.
Any ideas would be welcome.