mysql - LimeSurvey use JSON string from Database -
when utilize admin tool limesurvey add together additional field survey, attributedescriptions field in database looks this;
a:1: { s:11:"attribute_1"; a:4: { s:11:"description"; s:4:"unit"; s:9:"mandatory"; s:1:"n"; s:13:"show_register"; s:1:"n"; s:7:"cpdbmap"; s:0:""; } } when come in another, field in database looks this;
a:2: { s:11:"attribute_1"; a:4: { s:11:"description"; s:4:"unit"; s:9:"mandatory"; s:1:"n"; s:13:"show_register"; s:1:"n"; s:7:"cpdbmap"; s:0:""; } s:11:"attribute_2"; a:4: { s:11:"description"; s:9:"something"; s:9:"mandatory"; s:1:"n"; s:13:"show_register"; s:1:"n"; s:7:"cpdbmap"; s:0:""; } } i need dynamic way words "unit" , "something" in array can use.
this code json string;
$sql = $dbh->prepare($sql); $sql->execute(); $result = $sql->fetchall(pdo::fetch_assoc); print $result[0]["attributedescriptions"]; i terrible @ pdo. have tried;
$result = var_dump(json_decode($result[0]["attributedescriptions"], true); $result = var_dump(json_decode($result["attributedescriptions"], true); $result = var_dump(json_decode($result[0], true); i error;
warning: json_decode() expects parameter 1 string, array given in /var/www/html/surveys/survey-admin/functions/functions.php on line 189 null
this not json, serialized data:
serialize:
$serialized_data = base64_encode(serialize($data)); unserialize:
$unserialized_data = unserialize(base64_decode($serialized_data)); base64_encode() used avoid corruption, if info corrupted unserialize() homecoming false.
mysql json pdo
No comments:
Post a Comment