This topic is locked

Afteradd event

6/9/2007 9:44:08 AM
PHPRunner General questions
V
vytb author

Hello list,
would you help me with apparently elementary issue. I'm trying the afteradd event to insert primary autoincremental field value into another table with another primary autoincremental key.
Let's see the details:
parent table1:

field1 int autoinc primary key

field2 int
child table2:

field3 int autoinc primary key

field4 int foreign key (table2 is the child to the table1 on field1)
Evidently, if I use before add event, I receive '0' as the value inserted because this value does not exist before record is added.

If I place the same code as the after add event, for some reason I receive the errors that mention other fields not included in code. Does anybody have such an experience?

V
vytb author 6/9/2007

The code was following
[codebox]global $conn;

$strSQLInsert = "insert into table1 (field1, field2) values ('" . $values[""]. "','" . $values["field3"] . "')";

db_exec($strSQLInsert,$conn);
return true;[/codebox]