FredyH / MySQLOO

MySQLOO
GNU Lesser General Public License v2.1
138 stars 55 forks source link

Callbacks of Queries are not called from Transactions #32

Closed meepen closed 5 years ago

FredyH commented 5 years ago

This is kinda by design, because you just have the callback of the entire transaction instead, where you have access to all the queries and their results. Maybe I should add that back though, either way it's at least missing from the documentation.

FredyH commented 5 years ago

I think one of the big problems I had back then is what callbacks should be called when an error happens? Let's say the transaction fails at query 4 out of 5, should it still call success callbacks of the queries 1-3? Probably not. Should it call the error callbacks? If so with what error message?

Same goes for query number 5 which never executed, call the error callback or none at all?

meepen commented 5 years ago

https://github.com/meepen/MySQLOO/commit/100a84f00819efbfb33c20a0f1291ef920541ba7

i just did it this way it calls success for everything that succeeded, then transaction has final say so i can modify anything back that i need from the callbacks

i also am only really using this for performance benchmarks

FredyH commented 5 years ago

Yeah, that's not a good idea, so we will keep it like it is and just update the documentation instead.

meepen commented 5 years ago

how do you get the data of multiple same prepared statements in he transaction callback?