Hi guys,
I am having trouble with mysql in a calc field.
I want to add a feature to a job tracking system I have that shows an operator what tooling setup they need to used based on the part number from the job they have been handed.
I have 2 tables, one is for tracking the jobs called 'manual_transmission_jobs'
and one for the tooling setup called 'dyno_setups'
The 'dyno_setups' table has a multi-select drop down with a list of part numbers that the row is suitable for (with eval populate from {manual_transmission_parts___part_number} and also a dropdown field called 'which_dyno' (the machine that the tooling list is for).
The 'manual_transmission_jobs' has a dropdown field called part number.
I have created 2 calc fields (because we have 2 machines that have different tooling setups for the same part number).
One machine is called 'axi', the other is called 'fl'
In each calc field I have some mysql code to calculate the rowid for the tooling setup for each machine.
But I can only ever get a result of '1' no matter what the variables are.
Here is my code;
Anyone have any idea what I'm doing wrong?
I am having trouble with mysql in a calc field.
I want to add a feature to a job tracking system I have that shows an operator what tooling setup they need to used based on the part number from the job they have been handed.
I have 2 tables, one is for tracking the jobs called 'manual_transmission_jobs'
and one for the tooling setup called 'dyno_setups'
The 'dyno_setups' table has a multi-select drop down with a list of part numbers that the row is suitable for (with eval populate from {manual_transmission_parts___part_number} and also a dropdown field called 'which_dyno' (the machine that the tooling list is for).
The 'manual_transmission_jobs' has a dropdown field called part number.
I have created 2 calc fields (because we have 2 machines that have different tooling setups for the same part number).
One machine is called 'axi', the other is called 'fl'
In each calc field I have some mysql code to calculate the rowid for the tooling setup for each machine.
But I can only ever get a result of '1' no matter what the variables are.
Here is my code;
PHP:
$db = FabrikWorker::getDbo();
$query = $db->getQuery(true);
$dyno = 'axi';
$query->clear()
->select('id')
->from($db->quoteName('dyno_setups'))
->where($db->quote('{manual_transmission_jobs___part_number_raw}'))
->like($db->quoteName('dyno_setups.for_testing'))
->where($db->quoteName('dyno_setups.which_dyno' . '=' .$dyno));
$db->setQuery($query);
$thepart = $db->loadResult();
var_dump((string)$query);
return $thepart;
Anyone have any idea what I'm doing wrong?
Last edited: