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 3 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"

2 Answers
Abu Ghufran answered 3 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

Getty Images4Edinson Cavani appears to have been assured he can play down the middleGetty Images4Cav.

Your Answer

5 + 16 =

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 / 5. Vote count:

As you found this post useful...

Follow us on social media!

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

Let us improve this post!