Skip to main content
18 events
when toggle format what by license comment
S Jul 21, 2022 at 15:40 history suggested Dharman CC BY-SA 4.0
Fix unreachable code
Jul 21, 2022 at 15:39 review Suggested edits
S Jul 21, 2022 at 15:40
Jul 13, 2022 at 9:17 comment added Your Common Sense Yes, it could work. I edited the answer accordingly. But in reality, when using a transaction, you often don;t just run several queries, but have some code inbetween. in this case in seems you'll have to use transaction() like this: phpize.online/sql/mariadb/7056252bffde86d1f7ff67fc617b5fc9/php/…
Jul 13, 2022 at 9:15 history edited Your Common Sense CC BY-SA 4.0
added 28 characters in body
Jul 13, 2022 at 9:11 comment added kviktor1230 Im now really confused, this is the good way? phpize.online/sql/mariadb/7056252bffde86d1f7ff67fc617b5fc9/php/… Btw just one more question, if I want to return the rowCount() from each query. Is that possible with this code? Thanks!
Jul 13, 2022 at 8:59 comment added Your Common Sense It is not the question you worded unclearly, but the code you posted. There, for some reason, you have two transactions - one for insert and one for update.
Jul 13, 2022 at 8:43 comment added kviktor1230 No, I want to run multiple queries and statements and In the end of the code run the transaction (commit), so if something happens I can rollback(). Sorry if I worded a little unclearly my question
Jul 13, 2022 at 8:38 comment added Your Common Sense But you don't need a transaction for just a single query?
Jul 13, 2022 at 8:37 comment added kviktor1230 phpize.online/sql/mariadb/7056252bffde86d1f7ff67fc617b5fc9/php/… This is how I tried. This is how you meant? Or I'm doing something wrong? Thank you!
Jul 13, 2022 at 8:22 comment added Your Common Sense but didn't you already did that? Didn''t you just put all the code you need into updateRows function? So you already have it. Though you don't need that method but call transaction() just directly. Can you show your updateRows method online? like on phpize.online
Jul 13, 2022 at 8:12 comment added kviktor1230 Today I tried out your code and also created an UPDATE statement but Im not sure that Im understand right your method to wrap queries (statements) to transaction() method. So what I tried is I created a new method updateRows() like your method multiInsert() but without foreach loop. It's working fine. But what I don't understand is you wrote me that I don't (necessary) need to create new methods only I need to add my code to transaction() method if I want. Can you write me an example of how you mean that part of your code? "write any code you want to wrap into transaction" Thanks again!
Jul 13, 2022 at 4:56 comment added Your Common Sense By the way, you don't have to limit yourself to just one question. Quite contrary, the more questions you ask, the better answer I can make.
Jul 12, 2022 at 14:46 comment added Your Common Sense it is not multiInsert that allows for different queries, but transaction(). You just put any code where the comment "// write any code you want to wrap into transaction" stays. It can be insert, update, delete or whatever in any combinations
Jul 12, 2022 at 14:26 comment added kviktor1230 Thanks for your answer, its helped me a lot and I realized how much I still need to learn to understand everything. Just a side question, can I use in your method named multiInsert() UPDATE statement? "not only insert queries are allowed but any kind of query" Thank you again!
Jul 12, 2022 at 13:29 vote accept kviktor1230
Jul 12, 2022 at 13:18 history edited Your Common Sense CC BY-SA 4.0
added 539 characters in body
Jul 12, 2022 at 12:21 history edited Your Common Sense CC BY-SA 4.0
deleted 4 characters in body
Jul 12, 2022 at 12:09 history answered Your Common Sense CC BY-SA 4.0