thellie
Member
The plugin is set to run a MySQL query which deletes rows in related tables. The query works correctly in PHPMyAdmin, and the PHP plugin runs without an error, except it doesn't delete the rows. If I put in an integer instead of the variable, the plugin deletes the rows correctly.
I've checked what the variable pulls in and it's the correct data. I'm stumped after spending hours on this, trying all sorts of combinations... please look at the code to see if I'm missing something obvious.
Code with integer - deletes all related rows in all tables correctly
Code with variable
I've tried
Here's the variable in another element to test if the appform_id is correct
For the test row, the result is: newocn nocn = 5
which is the correct appform_id...
I've checked what the variable pulls in and it's the correct data. I'm stumped after spending hours on this, trying all sorts of combinations... please look at the code to see if I'm missing something obvious.
Code with integer - deletes all related rows in all tables correctly
Code:
$appformid = intval('{vol_appform___id}');
$myDb = Joomla\CMS\Factory::getContainer()->get('DatabaseDriver');
$myQuery = $myDb->getQuery(true);
$myQuery="
DELETE vol_personal, vol_passport, vol_family, vol_checks, vol_insurance, vol_pickup FROM vol_appform
INNER JOIN vol_personal
INNER JOIN vol_passport
INNER JOIN vol_family
INNER JOIN vol_checks
INNER JOIN vol_insurance
INNER JOIN vol_pickup
WHERE
(vol_appform.id=vol_personal.appform_id AND
vol_appform.id=vol_passport.appform_id AND
vol_appform.id=vol_family.appform_id AND
vol_appform.id=vol_checks.appform_id AND
vol_appform.id=vol_insurance.appform_id AND
vol_appform.id=vol_pickup.appform_id)
AND vol_appform.id ='4';
";
$myDb->setQuery($myQuery);
$myDb->execute();
Code with variable
Code:
$appformid = intval('{vol_appform___id}');
$myDb = Joomla\CMS\Factory::getContainer()->get('DatabaseDriver');
$myQuery = $myDb->getQuery(true);
$myQuery="
DELETE vol_personal, vol_passport, vol_family, vol_checks, vol_insurance, vol_pickup FROM vol_appform
INNER JOIN vol_personal
INNER JOIN vol_passport
INNER JOIN vol_family
INNER JOIN vol_checks
INNER JOIN vol_insurance
INNER JOIN vol_pickup
WHERE
(vol_appform.id=vol_personal.appform_id AND
vol_appform.id=vol_passport.appform_id AND
vol_appform.id=vol_family.appform_id AND
vol_appform.id=vol_checks.appform_id AND
vol_appform.id=vol_insurance.appform_id AND
vol_appform.id=vol_pickup.appform_id)
AND vol_appform.id = $appformid;
";
$myDb->setQuery($myQuery);
$myDb->execute();
I've tried
Code:
$appformid = intval('{vol_appform___id}');
$appformid =(INT) '{vol_appform___id}';
$appformid ='{vol_appform___id}';
Here's the variable in another element to test if the appform_id is correct
Code:
$appformid = intval('{vol_appform___id}');
$myname = '{vol_appform___first_name}' . ' ' . '{vol_appform___last_name}';
return $myname .' = '. $appformid;
For the test row, the result is: newocn nocn = 5
which is the correct appform_id...