Project

General

Profile

Actions

Feature #88056

open

mode insertIfNoUpdatePossible

Added by Bernhard Eckl almost 5 years ago. Updated over 1 year ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
Form Framework
Target version:
-
Start date:
2019-04-02
Due date:
% Done:

0%

Estimated time:
PHP Version:
7.0
Tags:
Complexity:
Sprint Focus:

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.

Actions #1

Updated by Susanne Moog almost 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.

Actions #2

Updated by Bernhard Eckl almost 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.

Actions #3

Updated by Susanne Moog almost 4 years ago

  • Status changed from Needs Feedback to New
Actions #4

Updated by Benni Mack about 2 years ago

  • Status changed from New to Needs Feedback

Can you share the your form.yaml configuration?

Actions #5

Updated by Bernhard Eckl about 2 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.

Actions #6

Updated by Riccardo De Contardi over 1 year ago

  • Status changed from Needs Feedback to New
Actions

Also available in: Atom PDF