mysqli-multi-query

mysqli multi_query followed by query

半城伤御伤魂 提交于 2019-12-10 10:15:51
问题 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 there a faster way to dump the results? I do not need them and just want to run the next query however I get the error: Commands out of sync; you can't run this command now Problem is the while ($mysqli->next_result()) {;} takes about 2 seconds which is a

Deleting tables with mysqli_multi_query()

我们两清 提交于 2019-12-08 12:27:00
问题 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 where ID_CLASS = 1delete from p' � la ligne 1) Any ideas? if (isset($_POST['butAj4'])) { $queryDel = "delete from inscription where NUM_INSCRIPTION = $NUM_INSCRIPTION"; $queryDel. = "delete from bource where ID_BOURCE = $ID_BOURCE"; $queryDel. =

How to implement MySQLi nested prepared statements? [duplicate]

无人久伴 提交于 2019-12-04 05:56:35
问题 This question already has answers here : Closed 7 years ago . I am trying to convert MySQL to MySQLi. And I cannot figure out why it brakes on $stmt2->execute(); and returns error: Call to a member function execute() on a non-object Any issue or valid implementing of it!? // SQL condition "WHERE group=''" where `group` is empty (NULL) $result = "SELECT id, name FROM table WHERE group='' ORDER BY array ASC"; if ($stmt = $mysqli->prepare($result)) { $stmt->execute(); $stmt->bind_result($id,

Why this PHP error occurs: “Strict standards: mysqli::next_result(): There is no next result set.”?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 20:08:39
问题 I have code, which is basically a copy of a php.net's code, but for some reason it does not work. Here is the code on php.net: <?php $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $query = "SELECT CURRENT_USER();"; $query .= "SELECT Name FROM City ORDER BY ID LIMIT 20, 5"; /* execute multi query */ if ($mysqli->multi_query($query)) { do { /* store first

Why this PHP error occurs: “Strict standards: mysqli::next_result(): There is no next result set.”?

邮差的信 提交于 2019-12-02 08:35:12
I have code, which is basically a copy of a php.net 's code, but for some reason it does not work. Here is the code on php.net: <?php $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $query = "SELECT CURRENT_USER();"; $query .= "SELECT Name FROM City ORDER BY ID LIMIT 20, 5"; /* execute multi query */ if ($mysqli->multi_query($query)) { do { /* store first result set */ if ($result = $mysqli->store_result()) { while ($row = $result->fetch_row()) { printf("

How to implement MySQLi nested prepared statements? [duplicate]

試著忘記壹切 提交于 2019-12-02 07:39:36
I am trying to convert MySQL to MySQLi. And I cannot figure out why it brakes on $stmt2->execute(); and returns error: Call to a member function execute() on a non-object Any issue or valid implementing of it!? // SQL condition "WHERE group=''" where `group` is empty (NULL) $result = "SELECT id, name FROM table WHERE group='' ORDER BY array ASC"; if ($stmt = $mysqli->prepare($result)) { $stmt->execute(); $stmt->bind_result($id, $name); while ($stmt->fetch()) { // SQL condition "WHERE group='$id'" where $id defined in $stmt->bind_result($id, $name); $result2 = "SELECT name FROM table WHERE

Why I am getting the Error “Commands out of sync; you can't run this command now”

夙愿已清 提交于 2019-12-01 05:43:46
The Documentation of the Error Mentioned in the Title Says If you get Commands out of sync; you can't run this command now in your client code, you are calling client functions in the wrong order. This can happen, for example, if you are using mysql_use_result() and try to execute a new query before you have called mysql_free_result(). It can also happen if you try to execute two queries that return data without calling mysql_use_result() or mysql_store_result() in between. From here: http://dev.mysql.com/doc/refman/5.0/en/commands-out-of-sync.html But In First Query I am not fetching any data

Why I am getting the Error “Commands out of sync; you can't run this command now”

↘锁芯ラ 提交于 2019-12-01 03:21:50
问题 The Documentation of the Error Mentioned in the Title Says If you get Commands out of sync; you can't run this command now in your client code, you are calling client functions in the wrong order. This can happen, for example, if you are using mysql_use_result() and try to execute a new query before you have called mysql_free_result(). It can also happen if you try to execute two queries that return data without calling mysql_use_result() or mysql_store_result() in between. From here: http:/

Multiple MySql WHERE Between Clauses

此生再无相见时 提交于 2019-11-30 16:07:00
问题 Newbie MySql programmer thanks for the patience. Im trying to track an Id number in a table where 3 different conditions are met this is what Iv got however the query dosent return any results where there are clearly matches in the table. Thoughts? SELECT * FROM `table` WHERE `x` BETWEEN 80 AND 20 AND `y` BETWEEN 120 AND 20 AND `z` BETWEEN 40 AND 10 LIMIT 0 , 30 Am I right in theory to think that this should work? 回答1: Close, but no cigar. :) SELECT * FROM table WHERE (x BETWEEN 20 AND 80)

select every other row in MySQL without depending on any ID?

拥有回忆 提交于 2019-11-29 07:46:21
Considering following table that doesn't have any primary key, can I select every other row? col1 col2 2 a 1 b 3 c 12 g first select must find: 2, 3 second select must find: 1, 12 is that possible? In unique MySQL fashion: select * from ( select * , @rn := @rn + 1 as rn from Table1 join (select @rn := 0) i ) s where rn mod 2 = 0 -- Use = 1 for the other set Example at SQL Fiddle. This should work for MySQL: SELECT col1, col2 FROM ( SELECT col1, col2, @rowNumber:=@rowNumber+ 1 rn FROM YourTable JOIN (SELECT @rowNumber:= 0) r ) t WHERE rn % 2 = 1 This uses % which is the MOD operator. And here