This topic is locked

Error inserting new record in external table

6/6/2022 10:24:23 AM
PHPRunner General questions
A
alfonso authorDevClub member

I have Phprunner Enterprise 10.7. In a project I have two databases open.
When a user registers, if he chooses option 1, I insert a new record in a table of Database 1. All correct
If the user chooses option 2, I insert a new record into a table from the second database connection. But I can't get it to work.
However, if you choose option 2 and insert the new record as in the first case, everything is correct.

Therefore, I suppose that it is not possible to add data from a table in DB1 to a table in DB2

// After successful registration

function AfterSuccessfulRegistration(&$userdata, $pageObject)
{

//** Insert a record into another table ****

if( $userdata["member_level"] == 1) {
$data2 = array();
$keyvalues = array();
$data2["email"] = $userdata["Email"];
$data2["nif"] = $userdata["nif_user"];
$keyvalues["nif"] = $userdata["nif_user"];
DB::Insert("table_A_bbdd_1", $data2, $keyvalues );
}
if( $userdata["member_level"] == 2) {
$data3 = array();
$data3["email_contacto"] = $userdata["Email"];
$data3["cif_empr"] = $userdata["nif_user"];
DB::Insert("table_B_bbdd_2", $data3);
}

Any idea. Thanks

Sergey Kornilov admin 6/6/2022

I see at least two problems here.

  1. The syntax of the first DB::Insert statement is incorrect, it only needs two parameters while you supplied three.
    Check the manual.


  2. You are talking about inserting data into a table that belongs to the second connection but you are not doing anything about setting the correct connection.
    Check the manual again.