This topic is locked

Passing composed primary key

7/21/2008 1:25:08 PM
PHPRunner General questions
E
ezelino author

I have two tables, mother and son.
The table mother has composed key of three fields.
How to insert register in the table son without having to type the key of the table mother again?

Thanks

J
Jane 7/22/2008

Hi,
We plan to add support of complex foreign keys in the next PHPRunner version.

It will be available in August.

scuba 9/10/2008

I have two tables, mother and son.

The table mother has composed key of three fields.
How to insert register in the table son without having to type the key of the table mother again?

Thanks


Ezelino,
is this what you need? You have to insert this code into Add page / After record added!!!!!
[codebox]//** Save new data in another table ****

global $conn,$strTableName;
$strSQLSave = "INSERT INTO YourTableName (id) values (";
$strSQLSave .= $keys["id"];
$strSQLSave .= ")";

db_exec($strSQLSave,$conn);
return true;
// return true if you like to proceed with adding new record

// return false otherwise[/codebox]

scuba 10/10/2008

sorry, forgot something. This should work!!
[codebox]$keys["id"]=mysql_insert_id();
//** Save new data in another table ****

global $conn,$strTableName;
$strSQLSave = "INSERT INTO YourTableName (id) values (";
$strSQLSave .= $keys["id"];
$strSQLSave .= ")";

db_exec($strSQLSave,$conn);
return true;
// return true if you like to proceed with adding new record

// return false otherwise[/codebox]