Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@We3D It also worked: now I'm officially a PHP human interpreter. Some programmers use AI to interact with servers. I'm a slave of a server. It uses my neurons to solve his problems
-
nitnip18102yserialize can be useful but frankly speaking I'd rather have a json string.
The PHP associative array
[ '692_1' => 'completed', '692_5' => 'completed', '692_2' => 'completed', '692_3' => 'completed', '692_4' => 'completed', '692_6' => 'completed']
can be serialized as
a:6:{s:5:"692_1";s:9:"completed";s:5:"692_5";s:9:"completed";s:5:"692_2";s:9:"completed";s:5:"692_3";s:9:"completed";s:5:"692_4";s:9:"completed";s:5:"692_6";s:9:"completed";}
which is a 174 characters string or json encoded as
{"692_1":"completed","692_5":"completed","692_2":"completed","692_3":"completed","692_4":"completed","692_6":"completed"}
which is a 121 characters string.
Databases can understand json, so I'd rather use that if possible. Serialize can do things that json can't, like dealing with objects and non-public properties but it's a hideous mess and it can get ugly with things like Closures and recursive objects. -
What's the surprise here? Your using WorstPress.
Gravity forms has a similar hell scape. It's freaking annoying to work with.
I will say this though, if you find yourself working with these kinds of serialized Json objects all the time I definitely recommend making a custom plug-in that uses the woocommerce API methods to serialize it for you and update the database.
Fixing a Woocommerce order editing manually a php serialized object in db. 😨️
rant
php wordpress