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
0
votes
2 answers

MySQL Multi Query store result second query

I am querying from two different tables in the database here and I can store the values from the first query but how do I store the information from the second query? $query = "SELECT * "; $query .= "FROM user_account "; $query .= "WHERE user_id =…
Freddos
  • 35
  • 6
0
votes
1 answer

Trouble with mysqli_multi_query

I'm having trouble with a mysqli_multi_query. I am able to INSERT INTO multiple times, but as soon as I include a DELETE, all subsequent queries do not work. Interestingly, this query works fine when pasted into the phpMyAdmin SQL box. SET…
Tim
  • 359
  • 3
  • 13
0
votes
2 answers

MySQL java jdbc MySQLNonTransientConnectionException: Got packets out of order

I'm currently having trouble sending a multiquery to a mysql database through java. The code is like this: String query = "Query 1; Query 2; Query 3;... Query 59" stmt =…
0
votes
2 answers

Insert into one Table, while updating another & File Upload

I am trying to update data in one table, and at the same time to insert a new row into a second table from a PHP form. When hitting submit I get an error message saying: Uncaught Error: Call to undefined method mysqli::exec() Below is my query on…
Leon Claassen
  • 183
  • 3
  • 12
0
votes
1 answer

foreach with mysqli_multi_query issue

I have the below code which works fine and updates each record contained in the array: $check_list = isset($_POST['check_list']) ? $_POST['check_list'] : array(); foreach($check_list as $check_list) { $query = "UPDATE `stock` SET `signature_id` =…
JonC
  • 11
  • 3
0
votes
3 answers

php mysqli_multi_query() stops inserting after first query

I'm trying to insert multiple rows into the same table using a mysqli_multi_query function, but it only executes the first query. I have tried adding the values to the end of the first query separated by a comma as well, but nothing seems to work. …
kurt
  • 17
  • 5
0
votes
1 answer

PHP Use of undefined constant bigdata

The code is working rightly with the error: Notice: Use of undefined constant bigdata - assumed 'bigdata' in C:\xampp\htdocs\dynamic_menu\index.php on line 4 Code as followed: //Set the database connection ($GLOBALS["___mysqli_ston"] =…
0
votes
1 answer

How to echo values in HTML that are coming from mysqli_multi_query in php

I am able to get values displayed from database when using mysqli_multi_query.But I am not able to print in my HTML code.Its Probably the issue with while loop. Below is my code which gives me the AVG for the three SQL statements. Only problem is…
Dev
  • 69
  • 2
  • 10
0
votes
1 answer

Multiple query and separate then for binding?

Is it possible to do multiple query's in the same .php and bind them to show in different places? For example I'm using:
0
votes
1 answer

PHP: How to Execute the Multiple Query using mysql_multi_query()

I am working on two SQL which are similar just difference is in first query stock is calculated between two dates and second query using current date. PHP: $sql="select all_dates.value1 as `Date`, sum(coalesce(`Inward(B_Qty)`, '0')) as `Inward`,…
Babaji
  • 33
  • 5
0
votes
1 answer

Import big CSV file to dependent MySQL tables using PHP with duplicate checking

I'm reading about 50,000+ .csv rows and create insert query. There is one dynamic value in insert query values. It's from SELECT if exists or INSERT if doesn't and get the inserted id. This is just testing purpose, just ignore the security…
Jeaf Gilbert
  • 11,495
  • 19
  • 78
  • 105
0
votes
0 answers

What am I missing with php command to INSERT INTO SELECT FROM?

I have a database and it contains four tables (for the sake of security I gave them disney character names) named huey, dewey, lewey and uncledonald. I would like to have the data from the columns deweysays in the table dewey, hueysays from the…
0
votes
1 answer

How to store results of multiple queries in different array variables

I need to get data from 2 different queries. I want to store them as 2 separate variables. First I tried this: // 1. Create a database connection $mysqli = new mysqli(DB_SERVER, DB_USER, DB_PASS, DB_NAME, DB_PORT); if ($mysqli->connect_errno) { …
Mike Gorski
  • 117
  • 2
  • 13
0
votes
1 answer

mysqli_multi_query(); numerous submissions

I have a PHP script that prepares 3 different SQL submissions. The SQL is valid for all of them. If I swap the order of the IF statements below, they all work. If the $ratesSQL is first then both 1) and 2) work. If either of the other two are first,…
DVCITIS
  • 1,067
  • 3
  • 16
  • 36
0
votes
0 answers

mysqli_multi_query and invalid query - no errors

Using PHP and mysqli_multi_query to create tables in database and insert some values. The code is below: mysqli_multi_query($GLOBALS["mysqli"], $mysql_query) or die(mysqli_error($GLOBALS["mysqli"])); The problem is that when invalid $mysql_query is…
Mindaugas Li
  • 1,071
  • 5
  • 15
  • 37