⚠ In case you've missed it we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This forum is read-only and soon will be archived. ⚠


as I can update a table after deleting a record in another?

callback triggers delete update two tree or four tables

  • Please log in to reply
1 reply to this topic

#1 Juan Carlos

Juan Carlos

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 29 October 2014 - 04:33 PM

Attached is a reference image, and actually think and apply it to multiple tables in different ways. 
 
Perhaps the solution could be using triggers, but I wonder if there is any way to do this using grocery crud, or otherwise appreciate the support of any member with the code of the trigger in mysql 
 
According to the attached image, I have two tables (project and client) 
 
First record of customers, so when I record the projects listed clients using set_relation.
 
Example, I have proposed the following records: 
 
Table Project: 
'proj001' 'project one', '02/01/2014', '29/10/2014', 'active', '1' 
 
Table Client: 
'1', 'one client', 'lima peru', '994584124', '1164661545' 
'2', 'client two', 'Caracas Venezuela', '154584124', '6498478965245' 
'3', 'client tree', 'santiago chile', '9545584124', '1654956245' 
 
So my first project log I linked to the first client (id_client = 1) when I delete the client "one client" my client crud value project.id_client already registered will remain "1" 
 
Eh researched and apparently can use the callback, but in your examples are always based on the same table, but not in two separate tables, not if someone can help me with a fully explicit example.

 

 

Attached Thumbnails

  • triggers.jpg


#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts

Posted 30 October 2014 - 06:41 AM

well writing a fully explicit exmple is going to be tough time...!! but yes callback is the solution. I will recommend u do a callback before delete

where u pick the client id and make a call to a function in model which deletes the associated projects for the client. Its not that tough to write / execute around. !!







Also tagged with one or more of these keywords: callback, triggers, delete, update, two tree or four tables

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users