0

I'm trying to commit a mysql multi query, but I can't...

When the mysqli_multi_query "query" has multiple queries cannot commit it. But, when the mysqli_multi_query "query" has an unique query, it is committed correctly. In both cases the execution is OK.

For example:

// No commits
$query = "insert into table(id) values (3); insert into table(id) values (4); insert into table (id) values (5);";
$connection = getConnection( ... );
mysqli_multi_query( $connection, $query );
mysqli_commit( $connection );

This code commits:

// This will commits
$query = "insert into table(id) values (3)";
$connection = getConnection( ... );
mysqli_multi_query( $connection, $query );
mysqli_commit( $connection );

1 Answer 1

1

You don't need to issue multiple queries for this, one INSERT query can contain many rows of values to insert at once. It's also much faster than issuing multiple separate queries.

INSERT INTO table (id) VALUES (3), (4), (5)

Then you can use mysql_query/mysqli_query instead of the rarely used multi query stuff.

Sign up to request clarification or add additional context in comments.

1 Comment

Yes but is a multi_query function, multi_query is multiple queries in one CALL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.