Update batch with CodeIgniter

后端 未结 2 861
旧时难觅i
旧时难觅i 2021-01-02 07:43

I\'m trying to do a small open CMS with CodeIgniter and I\'m now working on the categories system.

I\'m really stuck with that and after many tries and forum post I

2条回答
  •  遥遥无期
    2021-01-02 08:49

    First you cannot update multiple rows in one query, so there's nothing like insert_batch() for updates - you have to do it in a loop for each row. Next you should use 3rd table to link post id with category id in a one to many relation using foreign keys (InnoDB, worse performance) OR at least use category_id field in TABLE#2 that links to the category id, so you don't need to update this table in case of changes in TABLE#1.

提交回复
热议问题