Featured post
getting JSON data-tree from MySQL -
i have newsfeed similar facebook's newsfeed.
it means need not "straight" rows & cols datasets mysql more "trees" of data different length of branches (and different contents).
if go straight end lots of nested cycles in php - because each type of news needs different data sets.
example of newsfeed: 1) user "a" has added 2 new images (here have user_name, user_avatar, image_path_1, image_path_2 etc..) 2) user "b" has commented users's "a" image (here need user's "b" name, user's "b" avatar, image_path, comment_text, user's "a" name etc...)
see mean?
so want data mysql stored procedure converted json format.
{"news": [ {news_type: "new_images", user_name: "john", user_avatar: "0002.jpg", image_path: "/images/00123.jpg"} {news_type: "comment", user_name: "john", user_avatar: "0002.jpg", comment: "hello!"} ] }
i can conversion in mysql "concat" , "group_concat"... want ask opinion if it's idea or not - , if not better way.
thanks help!
update switched mongodb :)
this not wise. should use database server database work.
php automatically json encoding json_encode() if pass associative array. no point reinventing wheel or bogging down database server.
- Get link
- X
- Other Apps
Comments
Post a Comment