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

178 questions
3
votes
2 answers

Running multiple queries with mysqli_multi_query and transactions

I'm developing an update system for a Web Application written in PHP. In the process of the update I might need to execute a bunch of MySQL scripts. The basic process to run the scripts is: Search for the Mysql scripts Begin a transaction Execute…
Luís Cruz
  • 13,666
  • 16
  • 64
  • 89
3
votes
4 answers

How do I insert data into multiple tables in single query - Mysql

I have 8 query's to insert into 8 tables. I have tried with this But no use $mysql_db_hostname = "localhost"; $mysql_db_user = "root"; $mysql_db_password = ""; $mysql_db_database = "emp"; $con = mysqli_connect($mysql_db_hostname, $mysql_db_user,…
angel
  • 395
  • 1
  • 3
  • 13
3
votes
1 answer

mysqli multi_query followed by query

I am currently doing the following: $mysqli = new mysqli($server, $username, $password, $database); $mysqli->multi_query($multiUpdates); while ($mysqli->next_result()) {;} // Flushing results of multi_queries $mysqli->query($sqlInserts); Is…
Craig
  • 1,929
  • 3
  • 26
  • 36
2
votes
3 answers

How to execute multiple MySql query at same time?

I want to update my data, I use this but it won't update my data, the id still empty. So, how I can execute multiple SQL queries at the same time? $mysqli = new mysqli("a", "a", "a", "a"); if (mysqli_connect_errno()) { printf("Connect failed:…
ade guntoro
  • 23
  • 1
  • 5
2
votes
1 answer

PHP mysqli_multi_query large insert issue

I've tried many ways in an attempt to insert a large amount of data parsed from a text file (200,000 lines of text gets parsed into the array in about 2 seconds on my server so I know that part isn't the issue). The mysqli_multi_query I'm using…
das7002
  • 51
  • 1
  • 8
2
votes
2 answers

Is it possible to use LAST_INSERT_ID() in php for-loop?

Is is possible use the LAST_INSERT_ID() in php for-loop. I need to get the last playground PK as a FK in guardian table. Both needs to insert at a same time. Pardon me for not using PDO, i just want to get this thing to work first. $query = "INSERT…
Dexter
  • 3,590
  • 1
  • 23
  • 24
2
votes
2 answers

PHP - multiple variable usages in SQL statement

I have a project where I'm uploading a large CSV file (200 fields) into a database using PHP and an HTML form. With some help, I've finally gotten it working where it submits all 200 fields into one staging table in MySQL workbench, which was my…
H.Norman
  • 93
  • 1
  • 10
2
votes
2 answers

Is it possible to track the progress of a mysql script execution using PHP mysqli_multi_query?

The code is the following: if (mysqli_multi_query($conn, $query)) { $token = $_POST['token']; $query = " INSERT INTO _usuarios ( login_usuario, nombre_usuario, password_usuario, …
2
votes
1 answer

Strict standard - mysqli::next_result() - there is no next result. please call more_results() to check

This code is working correctly on my localhost (Xampp, PHP 5.4) but when I deploy this code on a server (Wamp, PHP 5.5), it's firing this error for $mysqli->multiquery(). Here is my code: if($mysqli->multi_query("CALL `wc_new_tyre_article`…
rut2
  • 711
  • 1
  • 8
  • 27
2
votes
1 answer

Multiple Insert in one transaction mysqli php5

I have 3 tables: user, student, studentdetails User's primary key is the foreign key for a field in table student (userid) and student's primary key is foreign key for a field in table studentdetails (studentid). I need to insert data from one…
Anx
  • 131
  • 2
  • 12
2
votes
1 answer

PHP Mysqli multi_query and trigger's delimiter

I need to run a db creation script inside PHP. Using multi_query I find some trouble with trigger delimiter: $sql=" CREATE TABLE `test` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT); DELIMITER ;; CREATE TRIGGER `tr_insert_test` AFTER INSERT ON…
Tobia
  • 8,015
  • 24
  • 90
  • 182
2
votes
3 answers

maximum query length in mysqli_query

How can I determine the maximum $query parameter received by function mysqli_multi_query (or mysqli_query), in PHP? I have a php program which generates a large string made of UPDATE sql commands, separated by ';' The Problem is that if that string…
Costel Socianu
  • 143
  • 1
  • 1
  • 10
2
votes
4 answers

How to identify the query that caused the error using mysqli_multi_query?

Using a example from elsewhere on SO to better catch 'hiding' errors. While the code below will catch and return an error, is it possible to improve this to report for which query the error occurred? With the code below, the output is: Columns:…
David
  • 3,055
  • 1
  • 31
  • 48
2
votes
2 answers

mysqli_multi_query not inserting to mysql db

I have used tutorials, examples and looked at numerous other questions about my problem and I still can't get it to work, I am relatively new to PHP and do not have any understanding of PDO. I have changed my code to mysqli rather than mysql to get…
PurpleSmurph
  • 1,882
  • 3
  • 24
  • 47
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,691
  • 6
  • 20
  • 31
1
2
3
11 12