This topic is locked

Add menu for two tables

6/26/2007 5:23:09 PM
PHPRunner General questions
P
punch author

Hello
i try to add a new record, but i want to write data in two different tables.

First parts of fields of the add menu should be written in table1, second part of fields in table 2.

How can i do this? I guess, with events (before add?), but i didn´t know the code for this.
Punch

Alexey admin 6/28/2007

Punch,
you need to add a record to second table manually using INSERT SQL statement then remove second table fields from $values array.

Here is the sample code for Before record added event:

global $conn;

$str = "insert into table2 (Field1,Field2) values ('".$values["Field1"]."','".$values["Field2"]."')";

db_exec($str,$conn);
unset($values["Field1"]);

unset($values["Field2"]);
return true;