INSERT...ON DUPLICATE KEY

INSERT...ON DUPLICATE KEY

ayzayz Posts: 63Questions: 23Answers: 1

For a PHP/ MySQL backend, how can I achieve INSERT ...ON DUPLICATE KEY UPDATE or IGNORE type operations?

This question has an accepted answers - jump to answer

Answers

  • ayzayz Posts: 63Questions: 23Answers: 1

    Well, from my understanding so far, it appears best way might be to use Editor in standalone mode, leverage the PHP libraries for stuff like validation and events but do my own SQL manipulations directly and then leverage the Editor infrastructure to again update the front-end.

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin
    Answer ✓

    Hi,

    Yes - this is one area that the provided libraries do not currently support I'm afraid. The libraries are designed to cover the 80% case (of the 80/20) rule. They aren't meant to be a complete SQL abstraction (in part because it allows them to potentially work with something like a plain CSV file, and in part because it would be fairly pointless to abstract 100% of SQL - we'd be better just using SQL directly!).

    For this particular case it would be possible to modify the PHP libraries to use on duplicate key update for an insert command since that is a relatively localised change, but if you want to do other more complex things such as group by then it would certainly need custom SQL written.

    Regards,
    Allan

This discussion has been closed.