Comments (7)
SQL doesn't support multiple UPDATES in a single query, if you want to update N rows (with different values for each row) you'll need to execute multiple queries.
from database.
@nixprosoft Your question is not clear to me. I did not understand what you're asking for.
The code below is doesn't pay attention to begin/commit commands and executing N queries
Your code is well doing a safe transaction with the default instance of the database.
Regarding your update query, we can not give an answer to that, as it is specific to your application.
Kindly note that Kohana Github repo is not the place to seek support. You might want to head to discourse.kohanaframework.org and ask your questions there.
Thanks!
from database.
Thanks. I'm not searching support. I'm telling you - there is a bug. For example, if I comment out line:
//Database::instance()->commit();
the query will execute instead. How do you explain that?
from database.
When I need to update N rows by transaction, I'm expecting 1 query to execute, not N. Am I correct?
from database.
Transactions don't affect the number of queries that execute. They just wrap a set of queries together, so you can ask the DB to cancel (rollback) or save (commit) them as a batch.
If you call $query->execute()
N times, with or without a transaction, then N queries will execute.
from database.
As @acoulton has well stated, your queries are executed. Whether they are committed or not, that is a different story.
When you omit the explicit commit, the queries get rolled back at the end, when PHP closes the database connection. Except when you have persistent database connections, your queries will get committed because of subsequent START TRANSACTION
calls, at the beginning of your script.
You probably know that returning count($items)
does not return any actual execution info from the database. Your Database
class might be fake, not doing real database stuff, and you can still have count($items)
returned.
I have added some references. Allow me to politely close the issue. Reopen if you still think there is bug.
http://dev.mysql.com/doc/refman/5.7/en/commit.html
http://dev.mysql.com/doc/refman/5.7/en/implicit-commit.html
Cheers!
from database.
My bad. Thanks for explanations.
Now I'm searching best practice to execute batch of queries (like INSERT N rows into one table with only one query) with QueryBuilder. Can you give me a link?
P.S. Sorry for off topic.
from database.
Related Issues (11)
- Bug in Database_Query_Insert: bad SQL for bulk insert HOT 2
- [Enhancement] Cassandra
- Why PDO driver doesn't allow list tables and columns HOT 4
- dry-run uses MySQL driver
- UNION will break with newer versions
- Insert query builder allows to use table alias in INSERT ... SELECT ... construction HOT 17
- Error in Select - AS (column aliases) query builder documentation HOT 3
- New session fails to insert after restart or destroy
- add MySQLi driver HOT 7
- Session trouble with searching-bots and Session::write() (more with Database_Session) HOT 23
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from database.