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

Convert columns to rows dynamically with records in Mysql - PHP

I have this in my database: Stud_id subject Total Abc12 Eng 60 Abc13 Eng 40 Abc12 Math 70 Abc13 Math 50 This is the output i expect: Stud_id Eng …
jst
  • 11
  • 2
0
votes
1 answer

details on mysqli_multi_query()?

I'm new to php. I'm trying to execute the queries below. I know I have to use mysqli_multi_query but all my tries so far have given me error. How do I execute these queries? I've read and tried to run other examples with failure.
VectorXY
  • 349
  • 1
  • 3
  • 12
0
votes
1 answer

Unable to get a multi line query executed

I have a multi line-command query that I want to execute. The query includes creating temporary tables and returning a table by using them. The code I tried:
Carl
  • 3
  • 2
0
votes
2 answers

multi query with prepared statements

I am trying understand how multi queries work in mysqli. But I confess that is not easy to understand. Basically how I can do these queries in a multi query? The page doesn't talk about prepared statements in multi queries. ($sql = $db ->…
anvd
  • 3,997
  • 19
  • 65
  • 126
0
votes
3 answers

updating the MySQL database with time by using mysqli_multi_query (php)

I'm using the below code in order to insert a text into the db and also to insert the current time (time only not date) $time = date("h:i"); $query = "UPDATE a_2020 SET done = 'yes' WHERE id = '2' ;"; $query .= "UPDATE a_2020 SET nowTime = $time…
Gerardo
  • 15
  • 5
0
votes
3 answers

UPDATE request for SQL fails on querying from PHP but works good on SQL command line

I am developing a page for stock maintenance. I am encountering a bizarre issue. When I run the PHP through AJAX everything works fine except for the mysqli_query part.
0
votes
0 answers

Using mysqli_multi_query in an existing function

I have a function that can make different types of database connections and, simplified below with only two such $ActionType values, it is the second one I am having difficulty with. No errors but no results either. Any ideas? The query contains…
DonP
  • 725
  • 1
  • 8
  • 27
0
votes
0 answers

How to get a single result from mysql_multi_query

I have a procedural php script which employs a mysqli_multi_query statement into which I must now add a SELECT statement. After many attempts, I have to admit that this appears to be a bit outside my ken. I need some help with the grammar… or…
Parapluie
  • 714
  • 1
  • 7
  • 22
0
votes
0 answers

Is there any performance drawback (and if yes, how much) if I use multi queries for MySQL w/ PHP every time?

I have a database wrapper class for MySQL which allow one query per call currently. I want to extend my database wrapper's support for processing multiple queries at once. It is clear for me that if I use the multi-query feature then I can reduce…
webprogramozo
  • 25
  • 1
  • 1
  • 5
0
votes
1 answer

Why does creating a table and then inserting multiple values return an error?

So I'm trying to create a table and then insert multiple values into it, like so: $servername = "localhost"; $username = "root"; $password = ""; $dbname = "someDbName"; $conn = mysqli_connect($servername,…
K. Medea
  • 3
  • 2
0
votes
1 answer

select from multiple table?

I have two table as below persons: ID , FNAME, LNAME ,GENDER 100 , A , B , M images: IMG_D,IMG_NM,ID_PERSONS 10 , 1.JPG , 100 20 , 2.JPG , 100 30 , 3.JPG , 100 the question is: I WANT QUERY RETRIEVE ALL COLUMNS FROM table persons and only…
0
votes
1 answer

How to insert a value into an auto_increment of a different table in the same string

I am using mysqli_multi_query to insert user's information and a default null profile photo, there are two tables for that, "esc_usuarios" for the personal data and "esc_usuarios_fotos" for the photos. What do I want is, after inserting the…
user8190735
0
votes
1 answer

MYSQL Select tableX from all databases

Let's say I have 50 databases that all have same schema and all have table 'plays'. Is there any possible way to SELECT all the data from table 'plays' from all the databases at once ? Is there any way to do this if I dont know how many databases I…
NVG
  • 3,248
  • 10
  • 40
  • 60
0
votes
1 answer

How do I use PHP to execute a SQL file in batch that contains thousands of statements?

I have a .sql file that contains a handful of TRUNCATE, DROP TABLE IF EXISTS and CREATE TABLE statements as well as thousands of INSERT and UPDATE statements. I'm trying to use PHP to execute all the statements in the file in batch as follows: $sql…
HartleySan
  • 7,404
  • 14
  • 66
  • 119
0
votes
1 answer

sql fails to execute via mysqli_multi_query

I am new to using mysqli_multi_query and haven't spent loads of time in php. My sql succeeds when I apply it directly in my db client (phpMyAdmin), but it does not execute from my php code. The return from this function is intented to be a 2-item…
Sasha
  • 3
  • 2