Asked 7 years ago
28 Dec 2016
Views 7765

posted

unserialize value in MySQL without php

unserialize value in database MySQL itself .by function of MySQL or any how.i dont want to use Php function unserialize()
table have suppose following serialized stored value.

a:3:{s:2:"sd";a:2:{i:0;a:2:{i:0;s:1:"i";i:1;s:2:"am";}i:1;s:2:"am";}s:1:"s";s:2:"am";s:1:"i";i:123;}


want to decode to back value and grab some content without use of php but at database MySQL

reason behind to decode at database level because i want to unserialize value and use it in same query . so single query do all thing .
normally what we do
1. we grab the value from database
2. than unserialize it in php
3.again use it to get some entry from database.

i want to make a single query which get data , unserialize it and again use it to same table/database.
Rasi

Rasi
answered Nov 30 '-1 00:00

use mysql_unserialize_php


mysql> CREATE FUNCTION unserialize_php RETURNS STRING SONAME 'unserialize_php.so';
mysql> select unserialize_php('O:8:"stdClass":2:{s:1:"a";s:4:"aaaa";s:1:"b";s:4:"bbbb";}', "$obj->a");
Post Answer