We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello, Cycle team!
I've been looking for an ability to write more complex insert queries. And so far I can't find a way to build a query like this one:
INSERT INTO some_table (`key`, `value`) VALUES (...) ON DUPLICATE KEY UPDATE `value` = VALUES(`value`)
As I understand PostgreSQL also has this functionality: https://www.postgresql.org/docs/current/sql-insert.html#SQL-ON-CONFLICT
So I believe It would be really great to be able to do something like that:
$this->database() ->insert('some_table') ->columns('key', 'value') ->values([['key_1', 'value_1'], ['key_2', 'value_2']]) ->onConflict(new Fragment('value = VALUES(value)')) // or ->onDuplicate(...) ->run();
Because now, I have to write it like:
$rows = [...]; $query = <<<SQL INSERT INTO `some_table` (`key`, `value`) VALUES $rows ON DUPLICATE KEY UPDATE `value` = VALUES(`value`) SQL; $this->database()->getDriver()->execute($query);
Any feedback on this would be appreciated.
The text was updated successfully, but these errors were encountered:
roxblnfk
No branches or pull requests
I have an idea!
Hello, Cycle team!
I've been looking for an ability to write more complex insert queries.
And so far I can't find a way to build a query like this one:
As I understand PostgreSQL also has this functionality:
https://www.postgresql.org/docs/current/sql-insert.html#SQL-ON-CONFLICT
So I believe It would be really great to be able to do something like that:
Because now, I have to write it like:
Any feedback on this would be appreciated.
The text was updated successfully, but these errors were encountered: