[thelist] mysql table field - storing multiple values

Renoir Boulanger renoirb at gmail.com
Thu Aug 23 20:18:10 CDT 2012

Yes. There is a way.

This is a json encoded string. We call that serialization.

json_encode(), and json_decode() will encode and decode array to json back an forth.

Try it, you'll see 

[1,2,3,4]   is a list with no key name given

{'id':3,'name':'Bob', 'familyName':'Mora
e'}   is a key value pair

[{...}],[{...}] is an array of non specidied key containing key value pairs silar to  array(array(),array());

Actually if you look at the code who generates this you will see the mechanism. During encode or decode you can say if you want to keep keys (see php.bet manual, please dont take my exact word its on top of my head).

So you know. PHP 5.4 now supports similar syntax without json_*

php.net/manual/en/language.types.array.php  see php 5.4 new features

Renoir Boulanger

(envoyé de mon téléphone)

Em 2012-08-23, às 20:40, Bob Meetin <bobm at dottedi.biz> escreveu:

> [{"id":"1","value":["1","3"]},{"id":"2","value":"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam turpis pede, vulput ate a, porta at, venenatis in, mi. Vivamus sagittis euismod felis. Aliquam ligul a risus, rhoncus sed, accumsan ac, ornare sed, est. In hac habitasse platea dict umst. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec consequat luctus felis.<\/p>"},{"id":"4","value":"james bond"},{"id":"14","value":""},{"id":"5","value":"1999"},{"id":"3","value":""},{"id":"12","value":"2"},{"id":"13","value":""},{"id":"7","value":""},{"id":"17","value":""},{"id":"8","value":""},{"id":"6","value":""},{"id":"16","value":""},{"id":"9","value":""},{"id":"10","value":""},{"id":"11","value":""},{"id":"18","value":""},{"id":"15","value":""},{"id":"19","value":""},{"id":"20","value":""}]
> The text represents a single field (called extra_fields) of a mysql table which I have to work with, cannot change the construct.  Using mysql or php, is there a correct way to parse out the content so that I can work with each element stored in the table?
> The first element, id: 1 stores 2 values from a multiple select list, 1, 3 -->> {"id":"1","value":["1","3"]}
> The second, id: 2 stores HTML text which may contain just about anything.
> -Bob
> -- 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt ! 

More information about the thelist mailing list