Member
Member
tw2003   18-09-2022, 10:28
#1

I need to update all codeblocks I used with several hundereds of my pictures as I want to change some things.
I'm able to run the update in phpmyadmin and see the correct result in corrsponding field. However if I open the gallery as admin the codeblock section is empty.
The update statement is like this:
update zp_images set codeblock=REPLACE(codeblock, '$conn = new mysqli(\"ip-adress\", \"user\", \"password\", \"datbasename\");', 'global $conn;\ninclude \'./twl/dbconnect.php\';\n');

This is the how the beginning of the codeblock field with the change looks in phpmyadmin:
a:1:{i:1;s:1428:"

Administrator
Administrator
acrylian   18-09-2022, 13:39
#2

You can have several codeblocks so the data is stored seralized. You have to cover that with your statement. I fear you cannot do this via MySQL easily directly. BEtter use PHP and Zenphoto's object model for this:

  • First get the data
  • unserialize it to get an array of all codeblocks,
  • update the array entry you want
  • Store it again serialized

Each object has methods for these tasks.

Also: If you do things like this perhaps consider to edit the theme itself (using the multiple_layouts plugin for example). Codeblocks are rather a workaround for simple calls. Today I would not introduce them as a feature anymore. Just beacuse maintainance is quite a pain if you used them a lot in various ways…

Member
Member
tw2003   20-09-2022, 08:48
#3

Thanks for explaining. At least I was not too stupid to do the correct SQL statement :-)

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.