Typically, one could use:
$conn = new mysqli($servername, $username, $password, $dbname);
and then later on:
$last_id = $conn->insert_id;
to get the id of last inserted record.
But how to do that with chronoforms, and then use it at next database-insert event?
I quess I could use custom code and write that $last_id = $conn->insert_id, but what to use instead conn, and would it work or is there some DB insert bu chronoforms itself in between?
Also, if I was to use such custom code, how then to get that $last_id to be used with next database save-method?
Thanks in advance!
$conn = new mysqli($servername, $username, $password, $dbname);
and then later on:
$last_id = $conn->insert_id;
to get the id of last inserted record.
But how to do that with chronoforms, and then use it at next database-insert event?
I quess I could use custom code and write that $last_id = $conn->insert_id, but what to use instead conn, and would it work or is there some DB insert bu chronoforms itself in between?
Also, if I was to use such custom code, how then to get that $last_id to be used with next database save-method?
Thanks in advance!
Hi seppo,
Why do you need that? If the table is set in MySQL to auto-increment then it will automatically get the next id when you save the record.
Bob
Why do you need that? If the table is set in MySQL to auto-increment then it will automatically get the next id when you save the record.
Bob
To use save to database again, for relational purposes: I need to save parts of the form to another table, and set there the id of the first database record, thus to keep them connected.
Also if I could need that information for dynamic form: If I need to reference that already saved part i.e. at another page of multipage form.
Also if I could need that information for dynamic form: If I need to reference that already saved part i.e. at another page of multipage form.
It will be available as part of the save data action -> {var:save_data#.id} (if the column is called id, otherwise use whatever your column is called)
This topic is locked and no more replies can be posted.