CodeIgniter Forums
[split] CI 3.1.2 Batch update not working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: [split] CI 3.1.2 Batch update not working (/showthread.php?tid=66597)



[split] CI 3.1.2 Batch update not working - tereaksmey123 - 11-10-2016

please help after i update 3.1.1 to 3.1.2 my update_batch not working


Code:
 $data = [
                   ['sl_id' =>  49, 'sl_move' => 1],
                   ['sl_id' => 48, 'sl_move' => 2]
               ];

               // error this update_batch line : Undefined index: sl_id

               if( ! $this->db->update_batch($this->table, $data, 'sl_id'))
               {
                   //FALSE
               }
               else
               {
                   //TRUE
               }
error sql syntax the following 

Code:
Error Number: 1064

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 'THEN '49' WHEN `sl_id` = THEN '48' ELSE `sl_id` END, `sl_move` = CASE WHEN `sl' at line 2

UPDATE `tbl_slide` SET `sl_id` = CASE WHEN `sl_id` = THEN '49' WHEN `sl_id` = THEN '48' ELSE `sl_id` END, `sl_move` = CASE WHEN `sl_id` = THEN '1' WHEN `sl_id` = THEN '2' ELSE `sl_move` END WHERE `sl_id` IN(,)

Filename: C:/wamp/www/CodeIgniter_Project/system/database/DB_driver.php

Line Number: 691

if i restore to version 3.1.1  it work but after update it give error above i had no idea


RE: [split] CI 3.1.2 Batch update not working - matrox445 - 12-08-2016

Hello,

Same problem here. You have to reverse the changes for 2 functions (update_batch and _update_batch) in the DB_query_builder file (system/database). Just copy / paste the functions of 3.1.1 version, it works for me.

Bye