How to edit serialized content in mysql
up vote
0
down vote
favorite
I am wondering if it is at all possible to edit an array that was serialized and stored in mysql directly in my mysql?
I am working with a plugin in WordPress that stores an array in mysql (serialized) but I need to change some of the array's values. I was hoping to edit the serialized string in the database but whenever I do the plugin is no longer able to read any of the data.
Is there a way I can edit the serialized data directly without breaking how the plugin reads it?
Cheers!
php mysql wordpress
add a comment |
up vote
0
down vote
favorite
I am wondering if it is at all possible to edit an array that was serialized and stored in mysql directly in my mysql?
I am working with a plugin in WordPress that stores an array in mysql (serialized) but I need to change some of the array's values. I was hoping to edit the serialized string in the database but whenever I do the plugin is no longer able to read any of the data.
Is there a way I can edit the serialized data directly without breaking how the plugin reads it?
Cheers!
php mysql wordpress
php.net/manual/en/function.unserialize.php
– WillardSolutions
Nov 5 at 1:51
I know how to unserialize it. But I want to edit the serialized string directly in mysql.
– Chris Hawkins
Nov 5 at 1:53
1
That seems like monumentally bad idea.
– Difster
Nov 5 at 1:57
I don't think this is possible. "serialize" is a language specific function. Not all languages does the same behavior when serializing array. And tho PHP is so clingy with Mr. MySQL, doesn't mean they have the same functions :)
– ACD
Nov 5 at 2:05
Agree with @Difster. If you want to store data in DB and be able to deal with it - use JSON format. MySQL supports a lot of JSON functions since 5.7 release so you can access data without problem.
– Anton
Nov 5 at 12:00
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am wondering if it is at all possible to edit an array that was serialized and stored in mysql directly in my mysql?
I am working with a plugin in WordPress that stores an array in mysql (serialized) but I need to change some of the array's values. I was hoping to edit the serialized string in the database but whenever I do the plugin is no longer able to read any of the data.
Is there a way I can edit the serialized data directly without breaking how the plugin reads it?
Cheers!
php mysql wordpress
I am wondering if it is at all possible to edit an array that was serialized and stored in mysql directly in my mysql?
I am working with a plugin in WordPress that stores an array in mysql (serialized) but I need to change some of the array's values. I was hoping to edit the serialized string in the database but whenever I do the plugin is no longer able to read any of the data.
Is there a way I can edit the serialized data directly without breaking how the plugin reads it?
Cheers!
php mysql wordpress
php mysql wordpress
asked Nov 5 at 1:45
Chris Hawkins
79216
79216
php.net/manual/en/function.unserialize.php
– WillardSolutions
Nov 5 at 1:51
I know how to unserialize it. But I want to edit the serialized string directly in mysql.
– Chris Hawkins
Nov 5 at 1:53
1
That seems like monumentally bad idea.
– Difster
Nov 5 at 1:57
I don't think this is possible. "serialize" is a language specific function. Not all languages does the same behavior when serializing array. And tho PHP is so clingy with Mr. MySQL, doesn't mean they have the same functions :)
– ACD
Nov 5 at 2:05
Agree with @Difster. If you want to store data in DB and be able to deal with it - use JSON format. MySQL supports a lot of JSON functions since 5.7 release so you can access data without problem.
– Anton
Nov 5 at 12:00
add a comment |
php.net/manual/en/function.unserialize.php
– WillardSolutions
Nov 5 at 1:51
I know how to unserialize it. But I want to edit the serialized string directly in mysql.
– Chris Hawkins
Nov 5 at 1:53
1
That seems like monumentally bad idea.
– Difster
Nov 5 at 1:57
I don't think this is possible. "serialize" is a language specific function. Not all languages does the same behavior when serializing array. And tho PHP is so clingy with Mr. MySQL, doesn't mean they have the same functions :)
– ACD
Nov 5 at 2:05
Agree with @Difster. If you want to store data in DB and be able to deal with it - use JSON format. MySQL supports a lot of JSON functions since 5.7 release so you can access data without problem.
– Anton
Nov 5 at 12:00
php.net/manual/en/function.unserialize.php
– WillardSolutions
Nov 5 at 1:51
php.net/manual/en/function.unserialize.php
– WillardSolutions
Nov 5 at 1:51
I know how to unserialize it. But I want to edit the serialized string directly in mysql.
– Chris Hawkins
Nov 5 at 1:53
I know how to unserialize it. But I want to edit the serialized string directly in mysql.
– Chris Hawkins
Nov 5 at 1:53
1
1
That seems like monumentally bad idea.
– Difster
Nov 5 at 1:57
That seems like monumentally bad idea.
– Difster
Nov 5 at 1:57
I don't think this is possible. "serialize" is a language specific function. Not all languages does the same behavior when serializing array. And tho PHP is so clingy with Mr. MySQL, doesn't mean they have the same functions :)
– ACD
Nov 5 at 2:05
I don't think this is possible. "serialize" is a language specific function. Not all languages does the same behavior when serializing array. And tho PHP is so clingy with Mr. MySQL, doesn't mean they have the same functions :)
– ACD
Nov 5 at 2:05
Agree with @Difster. If you want to store data in DB and be able to deal with it - use JSON format. MySQL supports a lot of JSON functions since 5.7 release so you can access data without problem.
– Anton
Nov 5 at 12:00
Agree with @Difster. If you want to store data in DB and be able to deal with it - use JSON format. MySQL supports a lot of JSON functions since 5.7 release so you can access data without problem.
– Anton
Nov 5 at 12:00
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Unserialize it and then serialize it again. Those are basic php functions.
$array = unserialize($serialized_data);
//do stuff to $array
$serealize = serialize($array);
I was thinking that... but the serialized string I get back appears to be different than the string in the database. So maybe they are storing the array in a different manner that simply serializing it.
– Chris Hawkins
Nov 5 at 2:03
WordPress just uses the PHP serialize/unserialize functions. There's no reason the plugins shouldn't be able to read it, I've done it before. If you or remove characters, elements etc. it does change the string. But it shouldn't render it unreadable. I should add, that I've done this many times.
– Difster
Nov 5 at 2:05
I ended up just writing some shortcode that pulled the serialized string then ran some code to update the required changes and put it back into the database. That worked.
– Chris Hawkins
Nov 5 at 8:20
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Unserialize it and then serialize it again. Those are basic php functions.
$array = unserialize($serialized_data);
//do stuff to $array
$serealize = serialize($array);
I was thinking that... but the serialized string I get back appears to be different than the string in the database. So maybe they are storing the array in a different manner that simply serializing it.
– Chris Hawkins
Nov 5 at 2:03
WordPress just uses the PHP serialize/unserialize functions. There's no reason the plugins shouldn't be able to read it, I've done it before. If you or remove characters, elements etc. it does change the string. But it shouldn't render it unreadable. I should add, that I've done this many times.
– Difster
Nov 5 at 2:05
I ended up just writing some shortcode that pulled the serialized string then ran some code to update the required changes and put it back into the database. That worked.
– Chris Hawkins
Nov 5 at 8:20
add a comment |
up vote
0
down vote
Unserialize it and then serialize it again. Those are basic php functions.
$array = unserialize($serialized_data);
//do stuff to $array
$serealize = serialize($array);
I was thinking that... but the serialized string I get back appears to be different than the string in the database. So maybe they are storing the array in a different manner that simply serializing it.
– Chris Hawkins
Nov 5 at 2:03
WordPress just uses the PHP serialize/unserialize functions. There's no reason the plugins shouldn't be able to read it, I've done it before. If you or remove characters, elements etc. it does change the string. But it shouldn't render it unreadable. I should add, that I've done this many times.
– Difster
Nov 5 at 2:05
I ended up just writing some shortcode that pulled the serialized string then ran some code to update the required changes and put it back into the database. That worked.
– Chris Hawkins
Nov 5 at 8:20
add a comment |
up vote
0
down vote
up vote
0
down vote
Unserialize it and then serialize it again. Those are basic php functions.
$array = unserialize($serialized_data);
//do stuff to $array
$serealize = serialize($array);
Unserialize it and then serialize it again. Those are basic php functions.
$array = unserialize($serialized_data);
//do stuff to $array
$serealize = serialize($array);
answered Nov 5 at 1:53
Difster
2,69111729
2,69111729
I was thinking that... but the serialized string I get back appears to be different than the string in the database. So maybe they are storing the array in a different manner that simply serializing it.
– Chris Hawkins
Nov 5 at 2:03
WordPress just uses the PHP serialize/unserialize functions. There's no reason the plugins shouldn't be able to read it, I've done it before. If you or remove characters, elements etc. it does change the string. But it shouldn't render it unreadable. I should add, that I've done this many times.
– Difster
Nov 5 at 2:05
I ended up just writing some shortcode that pulled the serialized string then ran some code to update the required changes and put it back into the database. That worked.
– Chris Hawkins
Nov 5 at 8:20
add a comment |
I was thinking that... but the serialized string I get back appears to be different than the string in the database. So maybe they are storing the array in a different manner that simply serializing it.
– Chris Hawkins
Nov 5 at 2:03
WordPress just uses the PHP serialize/unserialize functions. There's no reason the plugins shouldn't be able to read it, I've done it before. If you or remove characters, elements etc. it does change the string. But it shouldn't render it unreadable. I should add, that I've done this many times.
– Difster
Nov 5 at 2:05
I ended up just writing some shortcode that pulled the serialized string then ran some code to update the required changes and put it back into the database. That worked.
– Chris Hawkins
Nov 5 at 8:20
I was thinking that... but the serialized string I get back appears to be different than the string in the database. So maybe they are storing the array in a different manner that simply serializing it.
– Chris Hawkins
Nov 5 at 2:03
I was thinking that... but the serialized string I get back appears to be different than the string in the database. So maybe they are storing the array in a different manner that simply serializing it.
– Chris Hawkins
Nov 5 at 2:03
WordPress just uses the PHP serialize/unserialize functions. There's no reason the plugins shouldn't be able to read it, I've done it before. If you or remove characters, elements etc. it does change the string. But it shouldn't render it unreadable. I should add, that I've done this many times.
– Difster
Nov 5 at 2:05
WordPress just uses the PHP serialize/unserialize functions. There's no reason the plugins shouldn't be able to read it, I've done it before. If you or remove characters, elements etc. it does change the string. But it shouldn't render it unreadable. I should add, that I've done this many times.
– Difster
Nov 5 at 2:05
I ended up just writing some shortcode that pulled the serialized string then ran some code to update the required changes and put it back into the database. That worked.
– Chris Hawkins
Nov 5 at 8:20
I ended up just writing some shortcode that pulled the serialized string then ran some code to update the required changes and put it back into the database. That worked.
– Chris Hawkins
Nov 5 at 8:20
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53147301%2fhow-to-edit-serialized-content-in-mysql%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
php.net/manual/en/function.unserialize.php
– WillardSolutions
Nov 5 at 1:51
I know how to unserialize it. But I want to edit the serialized string directly in mysql.
– Chris Hawkins
Nov 5 at 1:53
1
That seems like monumentally bad idea.
– Difster
Nov 5 at 1:57
I don't think this is possible. "serialize" is a language specific function. Not all languages does the same behavior when serializing array. And tho PHP is so clingy with Mr. MySQL, doesn't mean they have the same functions :)
– ACD
Nov 5 at 2:05
Agree with @Difster. If you want to store data in DB and be able to deal with it - use JSON format. MySQL supports a lot of JSON functions since 5.7 release so you can access data without problem.
– Anton
Nov 5 at 12:00