ianaldrighetti / queryer

A simple, easy to use PHP database abstraction layer.
Other
0 stars 0 forks source link

Add ON DUPLICATE functionality to Insert Query builder #8

Open ianaldrighetti opened 10 years ago

ianaldrighetti commented 10 years ago

The Insert query builder should have an onDuplicate method which takes an UpdateQuery instance for executing an update if there is a key conflict.

MySQL supports this natively -- PostgreSQL and SQLite don't support this, though it could be emulated by attempting to run an update on the keys and if nothing is updated do the insert. Or the insert could be done and if it fails (SQLite does have an OR IGNORE flag) run the update.

There should be a onDuplicate method which takes an UpdateQuery (as stated), but there should also be a method called onDuplicateUpdate which is just invoked and will just have the query builder translate the insert query into an update query instead.