This topic is locked

Another beginner

1/27/2006 16:43:53
PHPRunner General questions
P
piki author

Hi,

I have problem solve event "before delete" !
$strSQLSave = "INSERT INTO AnotherTable (Field1, Field2) SELECT Field1, Field2 FROM ".strTableName." where ".$where;
how I write this?
My tables are:
table1->master

table2->slave
I delete from Master and want to be save in Slave.
I'm not a coder that's why I can't solve this "peaceofcake", but this is all I have to do in this matter.

I hope someone will tell me how to.
Anyway this is a great tool, people like me can do amazing things with that.

Sergey Kornilov admin 1/30/2006

Hi,
here is the code snippet you can use in BeforeDelete event to save the data in Slave table before it will be deleted from Master.

global $conn;

$strSQLSave = "INSERT INTO Slave SELECT * FROM Master where ".$where;

db_exec($strSQLSave,$conn);


This will work if your Master and Slave tables have the same structure. Otherwise you can use the following SQL string:

$strSQLSave = "INSERT INTO Slave (Field1,Filed2,Field3) SELECT Field1,Filed2,Field3 FROM Master where ".$where;

where Field1,Field2,Field3 are the fields to be copied from Master to Slave.

P
piki author 1/30/2006

Thanks Sergey, now it's works fine !!!
I used your first code and download latest PHPRunner version.