Forums

how do i convert this php in cc6?

zest96 17 Dec, 2020
Hi all,
I have this (function:PHP) code which is currently running fine in CC6.
Need some directions of making this using the CC6 tools.
read, save, loop...

thanks
$db =& JFactory::getDBO();
$query = "
SELECT *
FROM `#__chronoforms_data_recommendation`
WHERE `applicant_exist` = '' AND `year` = '2021'";

$db->setQuery($query);
$recommendations = $db->loadObjectList();


foreach ( $recommendations as $r ) {

// get matching applications
$query = "
SELECT `aid`
FROM `#__chronoforms_data_scholarship-application`
WHERE `applicant_firstname` = '{$r->applicant_firstname}'
AND `applicant_lastname` = '{$r->applicant_lastname}'
AND `year` = '2021'
LIMIT 1 ;
";
$db->setQuery($query);
$applicant_aid = $db->loadResult();

// check if any matches found
if ( !$applicant_aid ) {
//echo '<i class="icon-ban-circle red"> <i>No matches found</i></i>';
continue;
}
// Update the recommendation
$query = "
UPDATE `#__chronoforms_data_recommendation`
SET `applicant_exist` = {$applicant_aid}
WHERE `aid` = {$r->aid}
";
$db->setQuery($query);
$db->query();
}
// TODO
// in applications {view:table} display count of how many recommendations have the same applicant aid).
//count on-the-fly and not write to table.
Max_admin 23 Dec, 2020
Answer
if the code is working then keep it and return the value you need then use it in other actions, there is no need to build the code in CC6 tools
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
You need to login to be able to post a reply.