Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPLACE AND INSERT ... ON DUPLICATE KEY UPDATE support in Explorer #305

Open
tprochazka opened this issue Feb 15, 2024 · 1 comment
Open

Comments

@tprochazka
Copy link

Would be really useful to have

$this->db->table('table')->replace()

It is the same like INSERT, just with REPLACE is used

Or

$this->db->table('table')->inserOrUpdate($newData, $updateData)

Useful when update should for example increment some column, change date, etc.

Reference:
https://dev.mysql.com/doc/refman/8.0/en/replace.html
https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html

@diegosardina
Copy link
Contributor

While I agree it would be nice to have, it's too database-vendor specific.

PostgreSQL:

... ON CONFLICT (column) DO ...

FirebirdSQL:

UPDATE OR INSERT INTO table ... MATCHING (column) ...

Implementing MERGE (that is SQL standard) makes more sense. However it seems that MySQL still doesn't support it.

The best, for now, is an ad-hoc query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants