3列のテーブルがあります:
id (this is the id of my table)
parent (this is the parent)
position (and this is the position)
そして、私はこの配列を持っています$_arr['menu']
:
array (size=3)
13 =>
array (size=1)
'parent' => string '0' (length=1)
14 =>
array (size=1)
'parent' => string '13' (length=2)
25 =>
array (size=1)
'parent' => string '0' (length=1)
配列$_arr['menu']内のこれらの値を使用してテーブルを更新したいと考えています。
次のようなことをすると思いますが、1つのクエリで(おそらくケースインを使用して):
UPDATE table SET position = 1, parent = 0 WHERE id = 13;
UPDATE table SET position = 2, parent = 13 WHERE id = 14;
UPDATE table SET position = 3, parent = 0 WHERE id = 25;
その配列からこれらの値を取得する方法と更新を行う方法をマスターしてください!
どうもありがとう