vendredi 29 juin 2018

Bulk update in Laravel

I have a string with multiple update queries, example:

$string = "UPDATE `student` SET `isams_id`=0001,`name`='stu name',`registration_id`='258911',`classid`=2,`section`='A',`house_name`='ELM',`status`=1,`updated_at`='2018-06-29 06:49:15' WHERE `registration_id`='258911'; UPDATE `student` SET `isams_id`=0002,`name`='xxx,`registration_id`='258912',`classid`=3,`section`='A',`house_name`='sss',`status`=1,`updated_at`='2018-06-29 06:49:15' WHERE `registration_id`='258912';"

Like this, I have around 2500 update queries in my string. For bulk update I am using DB::select( DB::raw($string));. But this returns error like,

SQLSTATE[42000]: Syntax error or access violation: 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 'UPDATE `student` SET `isams_id`=0002,`name`='xxx',`registration_i' at line 1

How to resolve this. Please help me.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2yTFX17
via IFTTT

Aucun commentaire:

Enregistrer un commentaire