Jump to content


How to update a n n relation table

relation relation n_n

  • Please log in to reply
5 replies to this topic

#1 os123

os123

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 15 July 2015 - 11:47 PM

Hi everybody
 
I'm new in grocerycrud, I have a  question. Is it possible to create a relation_n_n that contains data (date, for example) you must update.
 
For example:
 
I have 2 tables
Employe (id_employe, nom, prenom)
Action(id_action, type, libelle)
 
and the relation table
EmployeAction (id_employe, id_action, date)
 
I would like to update the  "EmployeAction" table from the "Employe" table.
Is this possible with set_relation_n_n () function? How?
 
Could you help me please

 



#2 Paul Savostin

Paul Savostin

    Advanced Member

  • Members
  • PipPipPip
  • 229 posts
  • LocationUkraine

Posted 16 July 2015 - 12:00 AM

Hi! See docs on the grocery crud site and if after u will have a questions, write here :)



#3 os123

os123

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 16 July 2015 - 12:53 PM

Hi Paul, thank you for answer.
 
I saw the docs and like the example I am using this for the three tables 
 
 
$crud->set_relation_n_n('action', 'employeaction', 'action', 'id_employe', 'id_action', 'type', 'priority');
 
it works great, but my question is how can I enter information in the fields from the relation table in this case the date (or any other field)
 
what do you suggest? 


#4 Paul Savostin

Paul Savostin

    Advanced Member

  • Members
  • PipPipPip
  • 229 posts
  • LocationUkraine

Posted 16 July 2015 - 05:08 PM

All u can do that only add values before in related table and than update in current. Dynamicly add values u cant. But I guess I saw here on the forum similar question... so let search



#5 Raúl

Raúl

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 18 July 2015 - 11:58 AM

Hi 

I am having a similar case and I agree with Paul: it seems there is no way to automatically update it. So, I am implementing both updates to "master" and "relation" table in the same callback. However, I am having problems to get selected items. For the "main" table, I am referring to $post_array['first_name']

 to get the entered value, but for the selected entries (as I may have several), I understand I should get an array with selected ones: could someone provide an example??

$this->grocery_crud->set_relation_n_n('assignedgroup','users_groups', 'groups', 'group_id', 'user_id', 'description');
    	  
$this->grocery_crud->display_as('username','Identificador');



....

$post_array['username']
foreach ($post_array['assignedgroup'] as $assigned)	  


#6 Paul Savostin

Paul Savostin

    Advanced Member

  • Members
  • PipPipPip
  • 229 posts
  • LocationUkraine

Posted 18 July 2015 - 05:35 PM

I am not clearly understand your logic, can u explain more?

 







Also tagged with one or more of these keywords: relation, relation n_n

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users