This topic is locked

Insert and ID into another table

9/27/2007 4:52:54 PM
PHPRunner General questions
Allenh author

I have used a join statement so I don't seem to be able to use the parent/child page relationship so I have been trying to put the id from one table into another
I have tried

function BeforeAdd(&$values,&$message,$inline)

{

global $conn,$strTableName;

$strSQLInsert = "insert into user_profile (user_access_id) values (".$values["id"].")";

db_exec($strSQLInsert,$conn);

}
and
function BeforeAdd(&$values,&$message,$inline)

{

global $conn,$strTableName;

$strSQLInsert = "insert into user_profile (user_access_id) values (id)";

db_exec($strSQLInsert,$conn);

}
and
function BeforeAdd(&$values,&$message,$inline)

{

global $conn,$strTableName;
$strSQLInsert = "insert into user_profile (user_access_id)

SELECT `id`

FROM ".$strTableName." where ".$where;

db_exec($strSQLSave,$conn);

return true;
}
and
function BeforeAdd(&$values,&$message,$inline)

{

global $conn,$strTableName;
$strSQLInsert = "insert into user_profile (user_access_id)

SELECT `id`

FROM ".$strTableName." where id=".$values["id"].";

db_exec($strSQLSave,$conn);

return true;

}
and
function BeforeAdd(&$values,&$message,$inline)

{

global $conn;
$strSQLInsert = "insert into user_profile (user_access_id)

SELECT `id`

FROM user_access where id=".$values["id"].";

db_exec($strSQLSave,$conn);

return true;

}
any thoughts?

Sergey Kornilov admin 9/27/2007

Use AfterAdd event.

Allenh author 9/27/2007

Use AfterAdd event.


Which code option should work? - 1, 2, 3, 4 or 5?

Alexey admin 9/28/2007

Use this code in AfterAdd event:

global $conn;

$strSQLInsert = "insert into user_profile (user_access_id) values (".$keys["id"].")";

db_exec($strSQLInsert,$conn);

Allenh author 9/28/2007

Thanks! It worked!