說我5列id
,catname
和order
領域:用PHP更新mysql行的最佳策略是什麼?
+----+----------+-----+
| id | catname |order|
+----+----------+-----+
| 1 | cat1 | 2 |
| 2 | cat2 | 1 |
| 3 | cat3 | 3 |
| 4 | cat4 | 5 |
| 5 | cat5 | 4 |
+----+----------+-----+
,我想從一個數組更新這5個類別的順序,如:
array(1 => 3, 2 => 4, 3 => 5, 4 => 1, 5 => 2)
什麼最佳實踐?使用數組中的相應順序來選擇每一行並更新訂單字段?或者創建一個包含所有這些類別的順序數組的新表,並使用它用於使用例如userid命令和使用連接語句鏈接兩個表?
看看這個線程我的幫助: http://stackoverflow.com/questions/8532144/reordering-of-column-data-in-mysql –