Feature #88056
openmode insertIfNoUpdatePossible
0%
Description
Formhandler had the option insertIfNoUpdatePossible for records which did not exist. So if the where clause fails, an insert will be executed. It would be great for the form framework.
Updated by Susanne Moog over 5 years ago
- Status changed from New to Needs Feedback
Hey,
can you elaborate which where clause you mean and what your use case is? Which inserts are failing / what are you trying to update? I can't quite grasp what you want to achieve.
Updated by Bernhard Eckl over 5 years ago
I mean any where clause. If the where clause fails, it should insert instead of update.
E.g. a specific tt_address record belongs to an fe_user. The first time the user sends the form, it should insert a new tt_address record and the next times the user sends the form it should update the existing tt_address record (which matches the where clause).
The same like formhandler had insertIfNoUpdatePossible (http://www.typo3-formhandler.com/documentation/finisher/finisherdb/): If the update fails because the record to be updated does not exist, a new record will be created in the table.
Updated by Susanne Moog over 4 years ago
- Status changed from Needs Feedback to New
Updated by Benni Mack almost 3 years ago
- Status changed from New to Needs Feedback
Can you share the your form.yaml configuration?
Updated by Bernhard Eckl almost 3 years ago
I currently have a save to database finisher (without a solution):
finishers: - options: - table: tt_address mode: insert databaseColumnMappings: pid: value: 6475 name: value: '{firstname} {lastname}' tstamp: value: '{__currentTimestamp}' crdate: value: '{__currentTimestamp}' elements: image: mapOnDatabaseColumn: image title: mapOnDatabaseColumn: title skipIfValueIsEmpty: true gender: mapOnDatabaseColumn: gender lastname: mapOnDatabaseColumn: last_name firstname: mapOnDatabaseColumn: first_name email: mapOnDatabaseColumn: email studycourses: mapOnDatabaseColumn: course skipIfValueIsEmpty: true employer: mapOnDatabaseColumn: custom1 tasks: mapOnDatabaseColumn: custom2 reasonwhy: mapOnDatabaseColumn: custom3 skipIfValueIsEmpty: true uniprepared: mapOnDatabaseColumn: custom4 skipIfValueIsEmpty: true advantagesmalluni: mapOnDatabaseColumn: custom5 studylike: mapOnDatabaseColumn: custom6 skipIfValueIsEmpty: true opennesschange: mapOnDatabaseColumn: custom7 tenyears: mapOnDatabaseColumn: custom8 skipIfValueIsEmpty: true freshmanadvice: mapOnDatabaseColumn: custom9 skipIfValueIsEmpty: true - .......... identifier: SaveToDatabase
(tt_address has a few custom fields)
It should be with mode update and
options.whereClause = feuser = TSFE:fe_user|user|uid
(overwritten in Typoscript)
But if the where clause fails it should make an insert of the tt_address entry.
This way an fe_user could insert and update his own tt_address entry.
I think I could write a condition like
[getTSFE.fe_user.user["addressentry"] > 0]
And if true then overwrite mode insert with update. Should work.
Updated by Riccardo De Contardi about 2 years ago
- Status changed from Needs Feedback to New