Hi, I'm new to this forum so I'll try to keep it short. I've been using ChronoForms v4 with Joomla 2.5.11 on this project I'm working on for the last month, but I have found a little problem: I'm making a form where i need to customize the SELECT query and I haven't found a way to do it. Long story short, i have a simple SELECT that i have tried directly on the DB and it's running, but it includes a CASE/IF statement. Does anybody know how to do that in CF? Thanks
Forums
Problem with SELECT in CFv4
Hi zingeonaut,
You can do that most easily in a Custom Code action. It will be something like this:
Bob
You can do that most easily in a Custom Code action. It will be something like this:
<?php
$db =& JFactory::getDBO();
$query = "
SELECT `id`, IF(`a` = 1, 'b', 'c')
FROM `#__some_table`
WHERE `some_input` = 'somevalue' ;
";
$db->setQuery($query);
$form->data['my_results'] = $db->loadAssocList();
?>
Bob
Ok, but that way i wouldn't be able to use the Standard data displayer from chronoForms, right?
I also put a Custom code section inside the on Record Found in the DB Multi Record Loader
the Custom code is configured in Mode: Controller
I also put a Custom code section inside the on Record Found in the DB Multi Record Loader
<?php
foreach ($form->data as &$value) {
if($value->av_school=0)
{
$value='Sponsored'
}
else
{
$value='Available'
}
}
unset($value);
?>
the Custom code is configured in Mode: Controller
This topic is locked and no more replies can be posted.