INSERT...ON DUPLICATE KEY
INSERT...ON DUPLICATE KEY
ayz
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
This discussion has been closed.
Answers
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.
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 asgroup by
then it would certainly need custom SQL written.Regards,
Allan