Forums

DB save behaviour

csdpl 26 Jun, 2013
Hi,

the DB save generates either an INSERT statement or UPDATE statement. I would like to know on which basis chronoforms figures out whether to generate an INSERT or an UPDATE.

Also, the actual context of my question is this:

I have a chronoform that performs 3 steps when i click the submit button.

1. Inserts a new row into a table with an autoincrement field (DB Save)
2. Retrieves the autoid of the row that was just inserted
3. Updates another field in the same row whose value is based on the autoid (DB Save)

I encounter a problem where step 3 sometimes results in an INSERT statement, whereas i want it to always be an UPDATE.

Please advice.
GreyHead 26 Jun, 2013
Hi csdpl,

The Db Save action uses the Joomla! DB Methods; the rule is pretty simple. Check for to see if there is a value set for the table primary key in the data being saved. If there is one and it matches an existing record then UPDATE; otherwise INSERT.

Bob
This topic is locked and no more replies can be posted.