Deleting a record and the corresponding record in a grid with related tables?

QuestionsDeleting a record and the corresponding record in a grid with related tables?
Francisco José Segura Noya asked 8 years ago

Hi Abu.
I have two related tables to create a grid.
When I delete a record in the grid, only the record of one of the tables is deleted.
How to also delete the related record in the other table?
Thanks for your help.

This is the relationship

$g->select_command = "SELECT * FROM ( SELECT
r.id,
r.nombre,
r.apellidos,
LEFT(CONCAT(r.nombre, ' ', r.apellidos),20) as nombre_t,
SUBSTRING($campo_semana,2,21) as semana,
r.sala,
c.sala_comida,
regimen,
if((r.regimen = 0 OR r.regimen =''),'', r.regimen) AS regimen_final,
r.registro

FROM residentes r
INNER JOIN comidas c
ON c.sala_comida = r.sala

I delete the record of the "residents" table, but not delete the corresponding record in the table "comidas"

1 Answers
Abu Ghufran answered 8 years ago

You need to use on_delete event handler and write delete query code in callback function.
http://www.phpgrid.org/docs/#Grid_Events

Your Answer

17 + 14 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?