Insert dbjoin data into another table from repeat group

dimoss

Well-Known Member
Hi,

The following thread gives a solution when someone wants to insert data from repeat group into another table using the PHP form plugin:

http://fabrikar.com/forums/index.ph...rom-repeating-group-into-another-table.48826/

However the above refers to non-array elements. What if there is an element in the repeated group which is dbjoin (single select)?
I use the following and insert the record(-s) ok but obviously returns only the first occurence of the dbjoin element array:

PHP:
$db = JFactory::getDBO();
$query = $db->getQuery(true);
foreach ($this->data['fab_list_able_29_repeat___id'] as $key => $value)
{
  $query->clear()
      ->insert('fab_doubles')
      ->set('event = ' . $db->quote($this->data[fab_list_able_29_repeat___doubles_raw][0][$key]))
      ->set('assoc_a = ' . $db->quote($this->data[fab_list_able_29_repeat___assoc_raw][$key]))
      ->set('tournament = ' . $db->quote($this->data[fab_list_able_29_repeat___tournament_raw][$key]))
      ->set('player_a = ' . $db->quote($this->data[fab_list_able_29_repeat___player_id_raw][$key]));
  $db->setQuery($query);
  $db->execute();
}

The 'fab_list_able_29_repeat___doubles' is the dbjoin element on the repeated group.

Any help?
Thanks.
 
Last edited:
Try
$this->data[fab_list_able_29_repeat___doubles_raw][$key][0]

and/or
var_dump($this->data[fab_list_able_29_repeat___doubles_raw]) to see the structure
 
Thank u @troester :)
I should guess that first we grab the values with [key] and then we get the first occurence of the array :-(

My next problem is on the edit and I don't know how to make the code upserts (updates if repeat row already exists, inserts if it doesn't). As it is now inserts the same array every time I edit.
 
Last edited:
Try
$this->data[fab_list_able_29_repeat___doubles_raw][$key][0]

and/or
var_dump($this->data[fab_list_able_29_repeat___doubles_raw]) to see the structure

Hi @troester

Using:
$this->data[fab_list_able_29_repeat___doubles_raw][$key][0];

I get:
array(2) { [0]=> array(1) { [0]=> string(5) "U18MD" } [1]=> array(1) { [0]=> string(5) "U15MD" } }

How is it possible to get the string values comma separated and assign them into a variable in order to use it in a query? Note that the element is dbjoin in a repeat group.

Thanks.
 
Last edited:
Hi @dimoss !

did you manage to solve this question ?


I'm having a similar problem. So I'm performing a mathematical subtraction operation and it's not working :/

I looked in the documentation and it didn't work.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top