SOLVED: Accessing dbjoin data in a repeatable group

Status
Not open for further replies.

dimoss

Well-Known Member
Hi,

i have two fields in a repeatable group.
The first one is a dbjoin and the second a calc element which returns a calculation based on the dbjoin element value.
If I have only one instance of the repeatable group the calculation runs fine as the dbjoin is a string.
However in case of two instances the calculation doesn't work and returns NULL obviously because the data are in an array.
How it's possible to make it work for every instance?
Thanks.
 
I have tried using most of the examples but either I get NULL on var_dump or
0 Call to a member function getElementData() on null
 
Last edited:
I think I am clode but still not the expected.
I managed to get the array and then using implode to get the strings in comma separated values using a code like:

PHP:
$foo = FabrikWorker::JSONtoData($data['fab_list_able_28_repeat___singles_raw'], true);
$event = implode(',', $foo);

$db = JFactory::getDBO();
$query = "SELECT age_cat FROM fab_events INNER JOIN fab_list_able_28_repeat ON event_code = singles WHERE event_code IN ('$event')";
$db->setQuery( $query );
$age = $db->loadResult();
var_dump($age);

However using IF's like:
PHP:
if ($age == 'S')
{return $senior;}
else if ($age == 'U21')
{return $u21;}
else if ($age = ='U18')
{return $u18;}
else if ($age == 'U15')
{return $u15;}
else
{return '';}

to return the proper result based on some extra queries I always get the same value on both instances.
I think that a possible solution could be using an identifier for the different rowid of the repeat db table or a loop.
But I am stuck..:-(
 
Last edited:
What do you expect to get? IN usually returns more than one record but loadResult will give you only the first one. Use loadObjectList ( or so, I'm not on my PC) , you can select multiple colums and get back multiple records

Gesendet von meinem SM-G930F mit Tapatalk
 
I know that and this is the problem.
Using loadColumn() I get the array as follows:

array(1) { [0]=> string(1) "S" } array(1) { [0]=> string(3) "U21" }
 
It seems that I was heading to the wrong diection :)
It was easier that I thought as the PHP Form Plugin onAfterProcess did the job.
The trick was to get the parent_id on the repeated table using the: '{rowid}'
Then with a usual UPDATE with CASE structure I managed to get it work!
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top