You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
insertOrUpdate( $insertion, $update ): Inserts a record with the $insertion values or, if it exists, updates the record with the $update values.
Please have a look at Laravel's Eloquent implementation of the updateOrInsert method.
I bet it does something like this INSERT INTO {$this->table_name} ( user_id, points ) VALUES( %d, %d ) ON DUPLICATE KEY UPDATE points = points + %d
insertOrSkip( $insertion ): Inserts a record with the $insertion values only if the item doesn't exist. Simple insert() throws the MySQL error (duplicate entry). The implementation is simple: INSERT IGNORE INTO instead of INSERT INTO
These methods would be so useful.
insertOrUpdate( $insertion, $update ): Inserts a record with the $insertion values or, if it exists, updates the record with the $update values.
Please have a look at Laravel's Eloquent implementation of the updateOrInsert method.
I bet it does something like this
INSERT INTO {$this->table_name} ( user_id, points ) VALUES( %d, %d ) ON DUPLICATE KEY UPDATE points = points + %d
insertOrSkip( $insertion ): Inserts a record with the $insertion values only if the item doesn't exist. Simple insert() throws the MySQL error (duplicate entry). The implementation is simple:
INSERT IGNORE INTO
instead ofINSERT INTO
Maybe you would also add this method
3. forceInsert( $insertion ): Inserts a record after deleting it if it already exists.
https://dev.mysql.com/doc/refman/8.0/en/replace.html
The text was updated successfully, but these errors were encountered: