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
1 answer

Php doesn't INSERT or ON DUPLICATE KEY UPDATE at once from JSon to MySQL

I want to insert the new records from Json file to the database or update the existing one with new values. I have the MySQL table(tbl_sales) as follows where id is primarykey: +-----------------+-------------+------+-----+---------+-------+ |…
S.Sakthybaalan
  • 499
  • 6
  • 20
0
votes
1 answer

Duplicate Record with multi_query returns 1, but is not inserting

I am trying to Duplicate a Record. The table has an auto-increment key. All in one trip to the DB, so I use multi_query It returns 1 but the record is not inserted into DB. From what I've read it should return TRUE on success or FALSE on…
Lixo
  • 71
  • 11
0
votes
1 answer

PHP and MySQLi multiple queries in a single string

I've got a number of variables that need to be looked up in a MySQL database, their values replaced with database entries, and then put together in a single string to display to the end user, code below. I've created the below code, which while…
WillMaddicott
  • 512
  • 6
  • 20
0
votes
0 answers

Mysql Query is not working and Apache port goes too high

This query is not working in xampp PMA: SELECT `wp_posts`.`post_title`,`wp_terms`.`name`,`wp_terms`.`term_id`,`wp_term_taxonomy`.`taxonomy` FROM `wp_posts`,`wp_terms`,`wp_term_taxonomy`,`wp_term_relationships` WHERE…
Sultan
  • 1
  • 7
0
votes
1 answer

Deleting tables with mysqli_multi_query()

I'm trying to delete my principle table 'eleve', with deleting others table which has their primary key in this one. I tried like in the attached code, but I got an error: (Erreur de syntaxe pr�s de 'from bource where ID_BOURCE = 1delete from class…
0
votes
2 answers

How to mysqli_fetch_row while using mysqli_multi_query

I'm trying to get the latest info about some specific person, and I'm using a query like SELECT * FROM Table WHERE Name LIKE 'Peter' ORDER BY ID DESC LIMIT 1 and SELECT * FROM Table WHERE Name LIKE 'Mary' ORDER BY ID DESC LIMIT 1 because in the…
NDSAC
  • 13
  • 1
  • 5
0
votes
1 answer

mysqli_multi_query not working in while loop php

guys, I am stuck here as I am trying to store all the data into row_cats and then call one by one. $get_cats = "select * from categories"; $get_cats .= "select * from products order by rand() LIMIT 0,4" $run_cats…
0
votes
2 answers

How to create json from mysqli_multi_query resultsets?

I'm trying to display data to bootstrap datatable (4 columns) using php and ajax from mysqli_multi_query(). I could not get the 2nd query working with UNION or INNER JOIN. I'm no programmer and managed to, almost, get the correct result, but for…
0
votes
1 answer

Count Left users in binary PHP MYSQL

I have a table: CREATE TABLE `users` ( `user_id` int(10) NOT NULL, `user_name` char(150) NOT NULL, `parent_id` int(10) NOT NULL, `leg` enum('l','r') NOT NULL, `status` enum('unactive','active','block') NOT NULL ) ENGINE=InnoDB…
0
votes
3 answers

How to use mysqli->multi_query()?

Can anyone show me how to use mysqli->multi_query() to execute multiple update/ insert queries on a single connection? Thanks. I did follow the tutorials in the PHP manual. But I have some issues. My batch of queries has 5 statements separated by…
Kayes
  • 1,016
  • 3
  • 15
  • 22
0
votes
1 answer

SQL Injection attack - the use of mysqli_multi_query()

I am learning mysql now and one of the subjects it touches is the security issue when dealing with user input - one concern is the injection attack. I tried to duplicate the attack the book demonstrated like add a query $query = "select * from…
ming
  • 19
  • 2
0
votes
2 answers

PHP - INSERT and save LAST_INSERT_ID() into a variable

I'm sorry about my PHP skills, but I'm just not figuring out how to do this simple task which is INSERT a new row and save its ID into a variable. Here's what I got: // mysql inserting a new row $sql = "INSERT INTO `order` (orderTitle,…
jruivo
  • 447
  • 1
  • 8
  • 22
0
votes
1 answer

How to execute 2 SQL queries one after the other using mysqli_multi_query in PHP

I was trying insert values simultaneously into MySQL database using mysqli_multi_query but it's not executing and going to if part showing alert message stating Record Insertion Failed. Below is my PHP code with query while (($emapData =…
Pradeep
  • 267
  • 4
  • 15
0
votes
1 answer

How to merge Two queries into one and result in one row

SELECT lp.lead_bucket_no , case when p.product = 'S-400' then qty end as 'S400' , case when p.product = 'Dish Antenna' then qty end as 'DishAntenna' FROM lead_products lp INNER JOIN products p ON p.product_id = lp.product_id WHERE type = 'stock'…
Dinesh Patil
  • 104
  • 2
  • 8