-
Notifications
You must be signed in to change notification settings - Fork 51
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
Return Affected Rows #12
Comments
Sure. Do a PR and I'll merge. Note that affected rows counts as 2 for duplicates. |
@votemike I'm not sure how to use this feature when inserting multiple rows at once, and I believe there is at least an imprecision in the docs. /*
* @return int 0 if row is not changed, 1 if row is inserted, 2 if row is updated
*/
public static function insertOnDuplicateKey(array $data, array $updateColumns = null) however with multiple inserts/updates the output is the sum of the single affected-rows values. It would be nice to return an array like [ 'updates' => 2, 'inserts' => 17 ] but is it even possible, I mean does MySQL even allow to discriminate between insert/update in a big single statement like the one the method creates? Thanks, and thank you @yadakhov for the great tool! 👍 |
Would it be possible to somehow grab the number of rows affected? At the moment all the methods return a bool whereas I'd like to know if an INSERT was actually done or ignored. It would be easy to use Laravel's affectingStatement() method, but that would change the API of your code.
Would it be possible to make this breaking change and bump the version number?
Or possibly save the number of affected rows and add a method to grab that value.
I should be able to do the work if you like.
The text was updated successfully, but these errors were encountered: