Connect MySQL Insert

Hello

I am trying to write to two other related databases when adding a new event. For example, when adding a new event for a new customer, update the customer table with a new customer name and add a link to a linkage table between the customer and said organisation.

I am able to add a new event, add the new customer to the customer table but then fail to get the ID from the new record, and then use that to run a second SQL query to update the linkage table between the customer and the organisation.

I start of with attaching a function to “beforeInsert”:
$scheduler->event->attach(“beforeInsert”, “custom_beforeInsert”);

I then run $scheduler->sql->query(‘INSERT … BLAH BLAH’); which run successfully.

What I need to do next is get the ID for that record, and then run a second INSERT query against another table using the new ID generated by the previous INSERT query.

Please can you help?

Thank you

$scheduler->sql->get_new_id();

returns ID generated during last insert operation.

Tried that - I get Call to protected method MySQLDBDataWrapper::get_new_id() from context.

I did however manage to resolve my problem by using $id_new=mysql_insert_id($resource);

Thanks

The latest version of connector (github.com/DHTMLX/connector-php) has this method as public, but direct usage of mysql_insert_id will work fine as well.