This topic is locked

Delete child record

11/10/2009 6:09:06 PM
PHPRunner General questions
L
lostinwoods author

Hi
I have two tables t1 & t2

t1 is parent with t1.id as a field

t1.id is being joined as inner join

also I'm inserting t1.id into t2.id_a whenever new record is added
how to delete from t2.id_a when a record in t1.id is deleted
I have tried

global $dal;

$rs = $dal->t2->Query("id_a=".$deleted_values["id"],"");

$data = db_fetch_array($rs);

if($data)

return false;

else

return true
but this is not working as i'm getting this error
php error happened
Technical information

Error type 256

Error description Unknown column 'id' in 'where clause'

URL localhost/pr/main_list.php?

Error file C:\wamp\www\pr\include\dbconnection.php

Error line 34

SQL query select * from t2 where id=API001
am i doing something wrong?

J
Jane 11/11/2009

Hi,
please check my changes below:

global $dal;

$rs = $dal->t2->Query("id_a='".$deleted_values["id"]."'","");

$data = db_fetch_array($rs);

if($data)

{

//delete data from t2

$dal->t2->Param("id_a") = $data["id_a"];

$dal->t2->Delete();

}

return true;
E
EagleClaw 11/11/2009



Hi,
please check my changes below:

global $dal;

$rs = $dal->t2->Query("id_a='".$deleted_values["id"]."'","");

$data = db_fetch_array($rs);

if($data)

{

//delete data from t2

$dal->t2->Param("id_a") = $data["id_a"];

$dal->t2->Delete();

}

return true;



After applying this code to the after delete code area of my parent table, I get this message:
Fatal error: Can't use method return value in write context in ...output\include\invoices_events.php on line 25
I am using the latest phprunner version available, and MySQL as the database.
Thanks.

J
Jane 11/12/2009

Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

L
lostinwoods author 11/12/2009



Hi,
please check my changes below:

global $dal;

$rs = $dal->t2->Query("id_a='".$deleted_values["id"]."'","");

$data = db_fetch_array($rs);

if($data)

{

//delete data from t2

$dal->t2->Param("id_a") = $data["id_a"];

$dal->t2->Delete();

}

return true;



Thank you Jane
but I got this error message
Fatal error: Can't use method return value in write context in ...
what am I doing wrong? I have added the event on "Before records deleted" page

Sergey Kornilov admin 11/12/2009

Impossible to tell what's wrong without seeing your files.
Publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.