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

How to insert two or more rows into table using mysqli_multi_query() with out insertion errors?

I need to insert rows to more than one table and the number of rows that I need to insert is not fixed . I am using mysqli_multi_query() to do all my insert queries in a single step. I need to execute all my queries successfully or else if one of…
Anuraj TS
  • 19
  • 4
0
votes
1 answer

java Multi query from Mysql using netbeans

I have java code which retrieve some data from MySQL with appropriate code in netbeans.The code is below. I want to do multi query such as for example finding total number of products and so on.could you help me please. thanks in advance import…
developer
  • 25
  • 1
  • 11
0
votes
1 answer

multi_query does not run within a loop

A multi-query that I've put into another query does not run. The stored procedures in the inner query were not executed. The multi query alone is running well, but inside the loop it does not. Cold you please check, why InnerQuery does not perform…
Peter
  • 1,224
  • 3
  • 16
  • 28
0
votes
2 answers

Error to perform a query with SET by PHP on MySQL

I tryed to perform this query: $q = "SET @userId := (SELECT user_id FROM users WHERE user_email='$userEmail' AND user_token='$userToken' ); SELECT …
Luca122131
  • 115
  • 2
  • 9
0
votes
0 answers

Call to mysqli::query and mysqli::execute don't return errors, but aren't executed in the database

I'm trying to execute a DROP TEMPORARY TABLE statement. I've run the statement using MySQL Workbench and it works there. I've made sure I'm successfully logged in as the same user in both PHP and MySQL Workbench. I've tried using both…
Mike
  • 1
0
votes
1 answer

Codeigniter activerecord query continuously runs

When I try to run the follow query it never returns anything, it just keeps running. What am I doing wrong with it? $this->db->distinct('customer.Name') ->from('customer') ->from('invoicelinedetail') …
Jeremy Jackson
  • 2,247
  • 15
  • 24
0
votes
0 answers

var dump outputting bool(false)

Having problems at the moment when inserting into a database im running to different mysqli queries to insert into the same table but inserting into different fields when running this the second query that is inserting into order_contents selected…
user3080577
  • 5
  • 1
  • 5
0
votes
1 answer

using mysqli_multi_query to extract some data and re-enter it in a different table

I am trying to rewrite a piece of code that used several mysql_query calls to use one mysqli_... but cannot get it to work. If I simply replace my mysql_query statements with mysqli_query statements in the same place I get "Commands out of sync;…
0
votes
2 answers

mysqli_multi_query with CREATE TABLE and INSERT INTO

$query = "INSERT INTO abc VALUES ('1', '2', '3')"; $send_to_mysql = mysqli_query($connection, $query); OK. $query = "CREATE TABLE abc (a varchar(255), b varchar(255), c varchar(255))"; $send_to_mysql = mysqli_query($connection, $query); OK. $query…
0
votes
0 answers

PHP multi_query returns Error: Unknown column 'Type' in 'field list'

I wrote my very first PHP script which imports a csv file into a database, treats it and exports it again into another csv file. The problem is that even though I can check de database in phpMyAdmin and the column "Type" do exist, when I run the…
0
votes
1 answer

MySQL Multi Query - building in additional SQL parameters

I have the following code: $query .= "SELECT COUNT( ". $r ." ) AS Total, (SELECT COUNT( ". $r ." ) FROM tresults WHERE ". $r ." >=750) AS Eng, (SELECT COUNT( ". $r ." ) FROM tresults WHERE ". $r ." >=450 AND ". $r ." <=749) AS Pas, (SELECT…
Homer_J
  • 3,277
  • 12
  • 45
  • 65
0
votes
1 answer

MySQLi Multi Query code issue

I have the following: /* execute multi query */ if ($mysqli->multi_query($query)) { $n = 0; do { /* store first result set */ if ($result = $mysqli->store_result()) { $i = 1; $p = 1; while ($row =…
Homer_J
  • 3,277
  • 12
  • 45
  • 65
0
votes
1 answer

How do I get second result set from PHP multiquery statement?

I would like to get the results only from the second query in this multiquery statement. Presently, the way I have it constructed I get the results from both query statements: $query = ("call calcfields2_new('$_SESSION[Userid]');"); $query .=…
user2232681
  • 839
  • 4
  • 16
  • 33
0
votes
2 answers

Can not get multi_query() to work

EDITED: Working code below! //* opens a connection to a MySQL server */ $mysqli = new mysqli($host, $username, $password, $database); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); …
Brian V.
  • 37
  • 1
  • 8
0
votes
1 answer

mysql time_zone not used?

I'm trying to insert or update entries in a table, to Athens timezone. I'm using a shared hosting so I can't set global server timezone. When I run this multiple query: SET time_zone="Europe/Athens"; SELECT NOW(); I get the desired Athens time, but…
efrat
  • 11
  • 1
  • 1
  • 2