I want to delete one record and this table have 4 FK

QuestionsI want to delete one record and this table have 4 FK
Cristian Engelmann asked 8 years ago

$g["on_delete"] = array("delete_podria", null, true);

$grid->set_events($g);

function delete_podria($data)
{
$str = "DELETE FROM podria WHERE n_gp = {$data["n_gp"]} and n_grupo = {$data["params"]["n_grupo"]} and n_idioma = {$data["params"]["n_idioma"]} and n_usuario = {$data["params"]["n_usuario"]}";

mysql_query($str);
}

4 Answers
Abu Ghufran answered 8 years ago

This code should work if you have correct data in $data var.
You can debug it by:

{
phpgrid_error($data);

}

this will show the $data content in error message on grid.

Cristian Engelmann answered 8 years ago

Hi Abu,

SELECT n_gp,n_grupo,n_usuario,n_idioma FROM usuario_podria

$col = array();
$col["title"] = "n_gp";
$col["name"] = "n_gp";
$col["width"] = "10";
$col["hidden"] = true;
$col["align"] = "right";
$cols[] = $col;

$col = array();
$col["title"] = "n_grupo";
$col["name"] = "n_grupo";
$col["width"] = "10";
$col["hidden"] = true;
$col["align"] = "right";
$cols[] = $col;

$col = array();
$col["title"] = "n_idioma";
$col["name"] = "n_idioma";
$col["width"] = "10";
$col["hidden"] = true;
$col["align"] = "right";
$cols[] = $col;

$col = array();
$col["title"] = "n_usuario";
$col["name"] = "n_usuario";
$col["width"] = "10";
$col["hidden"] = true;
$col["align"] = "right";
$cols[] = $col;

ob_start();
print_r($data);
phpgrid_error(ob_get_clean());

This show n_gp => 14 only.

but I want to
n_gp => 14,n_grupo => 2,n_idioma => 1,n_usuario => 1

Thank you for your time!

Abu Ghufran answered 8 years ago
Cristian Engelmann answered 8 years ago

Thank you Abu. But doesn't work!
don't worry!
In the table (n=>1) create to a new field and concat those fields on one and now I can to delete one record.

Thank you again!

Your Answer

9 + 18 =

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?