Questions tagged [mysqli-multi-query]

Use this tag in case of multi-query execution in mysqli. mysqli_multi_query() executes one or multiple queries which are concatenated by a semicolon and returns TRUE on success or FALSE on failures.

mysqli_multi_query() executes one or multiple queries which are concatenated by a semicolon and returns TRUE on success or FALSE on failures. This can be performed either as procedural style or OOP style(see usage section).

Usage

Object oriented style

bool mysqli::multi_query ( string $query )

Procedural style

bool mysqli_multi_query ( mysqli $link , string $query )
  • bool is the return value type and depends on the passed $variable.
  • mysqli:: refers to the object initialised using stmt_init() or mysqli_prepare() call.
  • $query is the query, as a string. Data inside the query should be properly escaped.

Miscellaneous

  • mysqli_query() - Performs a query on the database
  • mysqli_use_result() - Initiate a result set retrieval
  • mysqli_store_result() - Transfers a result set from the last query
  • mysqli_next_result() - Prepare next result from multi_query
  • mysqli_more_results() - Check if there are any more query results from a multi query

Related tag

173 questions
1
vote
1 answer

PHP mysqli multi query empty results

Im using mysqli multi query to do some inserts and updates in one big lump instead of doing them in lots of seperate queries, basically I don't care about the results even if it is an error and ive read on the PHP.net doc page for the multi_query…
Jack
  • 3,769
  • 6
  • 24
  • 32
1
vote
1 answer

Using count from subquery to determine if row should be included in result rows

I am building a website and I need a query to return users based on proximity using gps coordinates, but also only if the user also has a photo that is marked private. The photos table is called 'photos' and the identifier to whom the photo belongs…
1
vote
1 answer

What may be the cause to my php code does not run after mysqli_multi_query is called?

I simply tried using "mysqli_multi_query" function in my php code (Queries are separated by semi-colon) and it inserts data correctly. I'm not getting any error after "mysqli_multi_query" is called. But the php code below the "mysqli_multi_query"…
Ruwan Liyanage
  • 333
  • 1
  • 13
1
vote
1 answer

Is mysqli_multi_query the same as multiple calls to mysqli_query?

The documentation of mysqli_multi_query and mysqli_query doesn't say if calling mysqli_multi_query is the same as calling mysqli_query multiple times. Does anyone know the answer?
guigoz
  • 674
  • 4
  • 21
1
vote
1 answer

php-mysqli wait for the 'multi_query' queries to complete?

I am importing a mysqlsqldump as follows. $command = file_get_contents($dumpfile); $conn->multi_query($command); while (mysqli_next_result($conn)); // Flush out the results. I have stripped down the code here, to just focus on the problem. Now…
Mohd Abdul Mujib
  • 13,071
  • 8
  • 64
  • 88
1
vote
1 answer

mysqli_multi_query() repeats the fetched with null

I am trying to fetch all the users who know "Photoshop" and all their details from multiple tables using mysqli_multi_query(). And I am getting the results also, But there are some uninvited guests too along with the correct results which are null.…
user8893870
1
vote
1 answer

MySQLi Multi_Query Post

I am sending data to my PHP API using JSON. I want to send a push notification to my Android user with this API. I am facing one strange issue in it. From JSON, I am sending Mobile Number, Mobile Number Status and User Id. I have two table in my…
Khushi Patel
  • 93
  • 1
  • 8
1
vote
0 answers

Can I execute multiple queries using sqli multi_query but only return one result

I am executing multiple SQL insert commands and one select query in a single request to the database server but I get back a result for each command as well. Simplified example: $query = 'INSERT INTO table1 (column1) VALUES (123);' . 'SET…
johna
  • 10,540
  • 14
  • 47
  • 72
1
vote
1 answer

MySQLi multi_query wont return more than 1 results

When the result is limited to 1, everything works great. However, when I have more than 1 results...it doesn't return anything. $output = $conn->multi_query("CALL `test_discount`('022979', 1101, 1, 'W', 100, @out); SELECT @out AS `discount`;"); if…
Nikk
  • 7,384
  • 8
  • 44
  • 90
1
vote
1 answer

Is multi_query in PHP necessarily subsequent

Given the following example: $mysqli->query("SELECT * FROM `table`"); $mysqli->query("INSERT INTO `table` SET `x` = 'y' WHERE `x` = 2"); I have no guarantee that all queries are necessarily executed subsequently. Another process may intercept and a…
Arne TR
  • 46
  • 4
1
vote
2 answers

mysqli_multi_query fails on multiple inserts

Greetings, I'm having the following issue: When I attempt to execute several INSERT INTO queries using the mysqli_multi_query function, none of them are executed and I receive a standard "You have an error in your SQL syntax" error, but when I take…
1
vote
0 answers

how to know all INSERT SUCCESS in mysqli_multi_query

i have code, and that code generate this syntax: $sql = "INSERT.....,; INSERT......,; INSERT.....,; INSERT......;"; if(mysqli_multi_query($connection,$sql)){ echo "SUCCESS!"; }else{ echo "FAILED!"; } how to know ALL INSERT IS SUCCESS from…
Abdul Aziz Al Basyir
  • 1,104
  • 13
  • 28
1
vote
1 answer

MySQL search for id in (identically structured) multiple tables

I have products in 3 (identically structured) tables with 3 columns columns: id, date, requests. When searching for a specific product id I'd like to search in all tables (I don't know in advance in which table the product id can be found) table1 is…
dean2020
  • 645
  • 2
  • 8
  • 25
1
vote
1 answer

Prepared Statement to Insert and update different table in database

Please How can i use prepared statement to update one table and insert into another table. i did what i no was right but the when i submit the form on that page, it just give me a blank page and nothing happened in the two database see what it look…
Oba
  • 11
  • 1
1
vote
1 answer

Sort multi query array for a drop down menu

I have to relations: one with the times and one where the selected times go in after submitting a form. I'm trying to create a dropdown menu, which should be sorted. If a time slot is already occupied is should still show up in the drop down, but as…
Aldi Kasse 2
  • 143
  • 1
  • 13
1 2
3
11 12