Download the PHP package wwardaww/insert-on-duplicate-key without Composer
On this page you can find all versions of the php package wwardaww/insert-on-duplicate-key. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wwardaww/insert-on-duplicate-key
More information about wwardaww/insert-on-duplicate-key
Files in wwardaww/insert-on-duplicate-key
Package insert-on-duplicate-key
Short Description A trait for MySQL INSERT ON DUPLICATE KEY UPDATE.
License MIT
Homepage https://github.com/wwardaww/insert-on-duplicate-key
Informations about the package insert-on-duplicate-key
MySQL Insert On Duplicate Key Update Eloquent Trait
This Trait forked from yadakhov/ insert-on-duplicate-key(v1.2.0)
Orginal packet status :
Insert Duplicate Key Update is a quick way to do mass insert.
It's a trait meant to be used with Laravel's Eloquent ORM.
Installing
composer require wwardaww/insert-on-duplicate-key
Code Example
Multi values insert.
INSERT ON DUPLICATE KEY UPDATE ANOTHER SCHEME
INSERT ON DUPLICATE KEY UPDATE DEFAULT SCHEME
INSERT IGNORE
REPLACE INTO
created_at and updated_at fields.
created_at and updated_at will not be updated automatically. To update you can pass the fields in the insert array.
Run unit tests
Will this work on Postgresql?
No. On Duplicate Key Update is only available on MySQL. Postgresql 9.4 has a similar feature called UPSERT. Implementing UPSERT is left as an exercise for the reader.
Isn't this the same as updateOrCreate()?
It is similar but not the same. The updateOrCreate() will only work for one row at a time which doesn't allow bulk insert. InsertOnDuplicateKey will work on many rows.