How can I modify this data:
(13, 'µµ+3 ', 'Miecz +3', 1, 0, 0, 2, 32, 1, 16, '', 100, 0, 14, 4, 0, 15, 1, 0, 0, 0, 7, 22, 0, 0, 0, 0, 0, 15, 19, 13, 15, 21, -1, -1, -1, -1, -1, -1, 0, 1, 0),
(14, 'µµ+4 ', 'Miecz +4', 1, 0, 0, 2, 32, 1, 16, '', 100, 0, 15, 5, 0, 15, 1, 0, 0, 0, 7, 22, 0, 0, 0, 0, 0, 15, 19, 13, 15, 28, -1, -1, -1, -1, -1, -1, 30, 1, 0),
(15, 'µµ+5 ', 'Miecz +5', 1, 0, 0, 2, 32, 1, 16, '', 100, 0, 16, 6, 0, 15, 1, 0, 0, 0, 7, 22, 0, 0, 0, 0, 0, 15, 19, 13, 15, 35, -1, -1, -1, -1, -1, -1, 40, 1, 0),
(16, 'µµ+6 ', 'Miecz +6', 1, 0, 0, 2, 32, 1, 16, '', 100, 0, 17, 7, 0, 15, 1, 0, 0, 0, 7, 22, 0, 0, 0, 0, 0, 15, 19, 13, 15, 42, -1, -1, -1, -1, -1, -1, 50, 1, 0),
(17, 'µµ+7 ', 'Miecz +7', 1, 0, 0, 2, 32, 1, 16, '', 100, 0, 18, 8, 0, 15, 1, 0, 0, 0, 7, 22, 0, 0, 0, 0, 0, 15, 19, 13, 15, 49, -1, -1, -1, -1, -1, -1, 65, 1, 0),
(18, 'µµ+8 ', 'Miecz +8', 1, 0, 0, 2, 32, 1, 16, '', 100, 0, 19, 9, 0, 15, 1, 0, 0, 0, 7, 22, 0, 0, 0, 0, 0, 15, 19, 13, 15, 56, -1, -1, -1, -1, -1, -1, 80, 1, 0),
(19, 'µµ+9 ', 'Miecz +9', 1, 0, 0, 2, 32, 1, 16, '', 2000, 0, 0, 0, 0, 15, 1, 0, 0, 0, 7, 22, 0, 0, 0, 0, 0, 15, 19, 13, 15, 63, -1, -1, -1, -1, -1, -1, 100, 1, 0),
(20, 'Ŕĺ°Ë+0 ', 'Dlugi Miecz +0', 1, 0, 0, 2, 32, 1, 16, '', 400, 0, 21, 1, 0, 15, 1, 5, 0, 0, 7, 27, 0, 0, 0, 0, 0, 13, 15, 15, 19, 0, -1, -1, -1, -1, -1, -1, 0, 1, 0),
(21, 'Ŕĺ°Ë+1 ', 'Dlugi Miecz +1', 1, 0, 0, 2, 32, 1, 16, '', 400, 0, 22, 2, 0, 15, 1, 5, 0, 0, 7, 27, 0, 0, 0, 0, 0, 13, 15, 15, 19, 7, -1, -1, -1, -1, -1, -1, 0, 1, 0),
(22, 'Ŕĺ°Ë+2 ', 'Dlugi Miecz +2', 1, 0, 0, 2, 32, 1, 16, '', 400, 0, 23, 3, 0, 15, 1, 5, 0, 0, 7, 27, 0, 0, 0, 0, 0, 13, 15, 15, 19, 14, -1, -1, -1, -1, -1, -1, 0, 1, 0),
Into a query, like this:
UPDATE `itemproto`
SET `name` = 'µµ+3'
WHERE `id` = 13;
UPDATE `itemproto`
SET `name` = 'µµ+4'
WHERE `id` = 14;
…
UPDATE `itemproto`
SET `name` = 'Ŕĺ°Ë+2'
WHERE `id` = 22;
..etc. There are hundreds of data, I’ve just gave you a little cut, because file weight is a some nice MB. But ok, let me explain, what do I want to reach:
Fe. there is a line like this…
(13, 'µµ+3 ', 'Miecz +3', 1, 0, 0, 2, 32, 1, 16, '', 100, 0, 14, 4, 0, 15, 1, 0, 0, 0, 7, 22, 0, 0, 0, 0, 0, 15, 19, 13, 15, 21, -1, -1, -1, -1, -1, -1, 0, 1, 0),
Then the script should rewrite the above line into a query:
UPDATE `itemproto`
SET `name` = 'µµ+3'
WHERE `id` = 13;
You just need the following info from each line to build a query:
(13, 'µµ+3 ' , etc….
I think it can be done using preg_replace or preg_match, but I have no idea about the regex.
Anyway, I will try to explain one more time in case if you still don’t get it:
I got hundreds of lines like this (with random names, numbers) :
(13, 'µµ+3 ', 'Miecz +3', 1, 0, 0, 2, 32, 1, 16, '', 100, 0, 14, 4, 0, 15, 1, 0, 0, 0, 7, 22, 0, 0, 0, 0, 0, 15, 19, 13, 15, 21, -1, -1, -1, -1, -1, -1, 0, 1, 0),
Now the script should grep this info: (13, 'µµ+3, and based on these info, should build the following query:
UPDATE `itemproto`
SET `name` = 'µµ+3'
WHERE `id` = 13;
And thats all.
I know its a little bit complicated, but as you know, everything can be done using PHP. So thats why I’m using it, but um, in case if you still don’t understand the question, feel free to post a comment, and I’ll reply!
A somewhat simplistic solution: