• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
if exist update data else insert new data

#1
I have a table with images. The user can update the existing images or add new. After he can save and send all data with POST. I would like update the data for existing images and insert new rows if the images doesn't exist. What is the correct query for to do this in Codeigniter 4?

Thanks for the support.
Reply

#2
Try to fetch the image if it does not exist then an empty array will be returned.

Now you can use and if statement to check the returned array,
if empty insert image else update image.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
(05-14-2020, 04:25 AM)InsiteFX Wrote: Try to fetch the image if it does not exist then an empty array will be returned.

Now you can use and if statement to check the returned array,
if empty insert image else update image.

Thanks for your answer. If i have 5 images: 3 updated and 2 new...with a if statement i can update 3 images OR add 2 new images. Have i lost something in your answer?  Undecided
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.