admin管理员组文章数量:1389779
When I try to add user meta to empty array as: a:0:{}
it's replaced into database as s:6:"a:0:{}";
I just need to save it as I written as a:0:{}
this is my code:
$sassada = get_user_meta($current_user, 'custom_system');
if(empty($sassada)){
add_user_meta($sassada, 'custom_system', 'a:0:{}');
}
When I try to add user meta to empty array as: a:0:{}
it's replaced into database as s:6:"a:0:{}";
I just need to save it as I written as a:0:{}
this is my code:
$sassada = get_user_meta($current_user, 'custom_system');
if(empty($sassada)){
add_user_meta($sassada, 'custom_system', 'a:0:{}');
}
Share
Improve this question
edited Jun 2, 2017 at 4:12
CodeMascot
4,5372 gold badges15 silver badges25 bronze badges
asked Jun 2, 2017 at 3:37
YoguYogu
855 silver badges14 bronze badges
1
|
1 Answer
Reset to default 3API calls are API calls, not database writes. What and how information is stored in the DB is usually best left as an unknown since, unless explicitly defined in the API, it might change.
Specifically in this case, wordpress will serialize the value being passed, and since you are passing a string it is serialized as a string.
And if what you are after is storing an empty array, just pass an empty array as the value.
本文标签: phpa0 is replaced into database as s6quota0quot
版权声明:本文标题:php - a:0:{} is replaced into database as s:6:"a:0:{}"; 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744688315a2619838.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
$sassada
as the first parameter ofadd_user_meta
function ? It is wrong cause it should be user ID and secondly you are checking$sassada
is empty. That means only empty$sassada
goes there. – CodeMascot Commented Jun 2, 2017 at 4:21