mysqli-multi-query

How to use mysqli->multi_query()?

左心房为你撑大大i 提交于 2020-07-16 07:19:05
问题 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 semicolons. UPDATE scenes set UserID = '11111111' WHERE ID = '031DFDAD92F6F4AB64AF317C06D64089DF119EC2'; INSERT INTO surfaces (ID, Name, SceneID, SurfaceTypeID, Color) VALUES('5F9A7301C2D398C4D1B90BA5AA56A9DED3FAA639', 'front ',

How to execute custom delimiter query with mysqli multiquery

家住魔仙堡 提交于 2020-01-24 21:12:07
问题 I have the following sql script and I want to execute it with multi-query DELIMITER $$ DROP FUNCTION IF EXISTS `getAttendanceHistoryDates`$$ CREATE FUNCTION getAttendanceHistoryDates(processDate date) RETURNS TEXT DETERMINISTIC LANGUAGE SQL BEGIN DECLARE minDate date; DECLARE startYear int; DECLARE endYear int; DECLARE dateString TEXT; SET minDate = (SELECT MIN(date) FROM `ohrm_attendance_report`); SET startYear = YEAR(minDate); SET endYear = YEAR(processDate); SET dateString = processDate;

Cannot figure out how to run a mysqli_multi_query and use the results from the last query

旧街凉风 提交于 2020-01-09 03:39:06
问题 I've never used mysqli_multi_query before and it's boggling my brain, any examples I find on the net aren't helping me to figure out exactly what it is I want to do. Here is my code: <?php $link = mysqli_connect("server", "user", "pass", "db"); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $agentsquery = "CREATE TEMPORARY TABLE LeaderBoard ( `agent_name` varchar(20) NOT NULL, `job_number` int(5) NOT NULL, `job_value` decimal(3,1) NOT NULL,

PHP mysqli_multi_query large insert issue

自作多情 提交于 2020-01-04 06:01:10
问题 I've tried many ways in an attempt to insert a large amount of data parsed from a text file (200,000 lines of text gets parsed into the array in about 2 seconds on my server so I know that part isn't the issue). The mysqli_multi_query I'm using sends the queries in blocks of 5,000 (for some reason it refuses to do anything larger if I want to use multi_query more then once) OR if I split the text file down to 50,000ish rows I can insert them all at once in 2 seconds. If I do that then it

PHP mysqli_multi_query large insert issue

 ̄綄美尐妖づ 提交于 2020-01-04 06:01:02
问题 I've tried many ways in an attempt to insert a large amount of data parsed from a text file (200,000 lines of text gets parsed into the array in about 2 seconds on my server so I know that part isn't the issue). The mysqli_multi_query I'm using sends the queries in blocks of 5,000 (for some reason it refuses to do anything larger if I want to use multi_query more then once) OR if I split the text file down to 50,000ish rows I can insert them all at once in 2 seconds. If I do that then it

Insert into one Table, while updating another & File Upload

纵饮孤独 提交于 2019-12-25 09:16:47
问题 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 the PHP submit form: $link->exec("SET CHARACTER SET utf8"); // Sets encoding UTF-8 try { $link->beginTransaction(); $q1 = $link->prepare("INSERT INTO liquor_licenses_2 ( username , outlet_number , license_date , license , scanned_license , permit

mysqli_multi_query fails on multiple inserts

别说谁变了你拦得住时间么 提交于 2019-12-24 12:15:10
问题 Greetings, I'm having the following issue: When I attempt to execute several INSERT INTO queries using the mysqli_multi_query function, none of them are executed and I receive a standard "You have an error in your SQL syntax" error, but when I take the exact same string I passed to the function and paste into PHPMyAdmin and execute it, it works flawlessly! Here are the queries I am attempting to execute: INSERT INTO production VALUES( 120, 103, 10, 0, 0 ); INSERT INTO production VALUES( 120,

How to use async Mysql query with PHP PDO

倖福魔咒の 提交于 2019-12-23 09:41:08
问题 The Mysqlnd driver PHP 5.6 have opportunity to use a Async queries http://php.net/manual/en/mysqli.reap-async-query.php How to use Async queries with PDO? it is not work, code (PHP asynchronous mysql-query): $dbConnectionOne = new \PDO($cnn0, $conf['user'], $conf['pass']); $dbConnectionOne->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); $dbConnectionTwo = new \PDO($cnn0, $conf['user'], $conf['pass']); $dbConnectionTwo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);

How to identify the query that caused the error using mysqli_multi_query?

狂风中的少年 提交于 2019-12-12 21:12:19
问题 Using a example from elsewhere on SO to better catch 'hiding' errors. While the code below will catch and return an error, is it possible to improve this to report for which query the error occurred? With the code below, the output is: Columns: 18 Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FRO inventory' at line 1 Code being tested: $query = "SELECT * FROM orders WHERE location = 'IN' ORDER BY

How to create a view with mysqli_multi_query?

房东的猫 提交于 2019-12-11 13:46:22
问题 I'm developing a PHP application, that should be able to setup a project database and update it / its data definition, using a list of SQL files. Here is a first naïve quick&dirty written procedural prototype: <?php function executeSQLFiles(array $dbOptions, array $dbFiles) { $dbConnection = mysqli_connect($dbOptions['host'], $dbOptions['user'], $dbOptions['password'], $dbOptions['database']); if (mysqli_connect_errno($dbConnection)) { echo "Failed to connect to MySQL: " . mysqli_connect