The Slim Framework support forum has moved to This Tender forum is no longer maintained or monitored.

nested array in json response

John H's Avatar

John H

19 Apr, 2013 07:18 PM

I have a json response that looks like:


As you can see, the fav_things property is a nested array.

Up until now, I have had no problems with single properties updating in my database using Slim. I'm stuck on how to best update this array of properties as ONE into a row on my mysql db.

The error message I receive when Slim tries to accept this response and update the db is:

Type: ErrorException Code: 8
Message: Array to string conversion

How can I instruct Slim or my mysql code to interpret this nested array correctly?

my current code looks like

$sql = "UPDATE users SET
WHERE id=:id

$request = $app->request();
$response = $request->getBody();
$response = json_decode($response);

$STH  = $db->prepare($sql);
$STH->bindParam("name", $response->name);
$STH->bindParam("name", $response->city);
$STH->bindParam("name", $response->fav_things);
$STH->bindParam("name", $response->active);

Can anyone help me figure out how to get this fav_things nested property working?

Thanks! Any help is much appreciated!


  1. Support Staff 1 Posted by Andrew Smith on 22 Apr, 2013 12:41 PM

    Andrew Smith's Avatar

    Currently fav_things will be an array after json_decode, you cannot store this into the database as the PDO will try and convert this to string, hence why you get this error.

    You could serialize $response->fav_things and then store it.

    Also notice you are trying to bind only the name param over and over.

  2. Support Staff 2 Posted by Brian Nesbitt on 22 Apr, 2013 12:50 PM

    Brian Nesbitt's Avatar

    You can't embed documents in mysql.

    You have 3 options.

    1) As Andrew mentioned use to convert the array to a string and store that.
    2) Why not just store the json string?

    1 and 2 will depend on your querying needs

    3) Create an association table to store user fav things in as a one to many.

  3. 3 Posted by vir on 05 Apr, 2016 10:41 AM

    vir's Avatar

    good apply your net and there will come to be info expenses. Choose to the application’s website and struck the install button. nice.

  4. 4 Posted by Thanh McFarland on 07 Apr, 2016 08:25 AM

    Thanh McFarland's Avatar

    great. very helpful. cheers!
    i used it and its best.

  5. 5 Posted by ami on 21 Apr, 2016 07:28 AM

    ami's Avatar

    good If your mobile phone unit and your computer system will be not really on the same Wi-Fi network. You will receive a alert, but it’s all best suited. Simply just click Fine, nice.

  6. 6 Posted by rahul on 07 May, 2016 12:53 PM

    rahul's Avatar

    very useful cheers buddy

  7. 7 Posted by rahul on 07 May, 2016 12:54 PM

    rahul's Avatar

    and did you ever thought that
    is perfect alternative

  8. 8 Posted by rahul on 07 May, 2016 12:55 PM

    rahul's Avatar

    and even i think
    blackmart amazing

  9. 9 Posted by chehak Srivasta... on 16 May, 2016 09:36 AM

    chehak Srivastava's Avatar

    This is really awesome site and you must visit it now.

  10. 10 Posted by prabhas on 02 Jun, 2016 02:43 AM

    prabhas's Avatar

    this was the great website and i love this website

  11. 11 Posted by sehwag on 05 Jun, 2016 07:27 AM

    sehwag's Avatar
  12. 12 Posted by viru7 on 06 Jun, 2016 07:47 AM

    viru7's Avatar
  13. 13 Posted by viru7 on 06 Jun, 2016 07:48 AM

    viru7's Avatar
  14. 14 Posted by bala on 07 Jun, 2016 07:44 AM

    bala's Avatar
  15. 15 Posted by lala on 09 Jun, 2016 10:48 AM

    lala's Avatar
  16. 16 Posted by Very Nice on 12 Jun, 2016 03:49 AM

    Very Nice's Avatar
  17. 17 Posted by rama on 13 Jun, 2016 03:07 PM

    rama's Avatar
  18. 18 Posted by nikky on 14 Jun, 2016 10:55 AM

    nikky's Avatar

    For Easy Surfing Download The App Cloud VPN apk Aap Here

  19. 19 Posted by Prabhaa on 14 Jun, 2016 01:45 PM

    Prabhaa's Avatar

    Thanks for sharing.............

  20. 20 Posted by jaya on 15 Jun, 2016 02:36 PM

    jaya's Avatar

    ;) cool. Thank you for sharing this.

  21. 21 Posted by Share it on 16 Jun, 2016 06:34 AM

    Share it's Avatar

    Check this for SHAREit for Windows PC

  22. 22 Posted by instagram apk on 17 Jun, 2016 01:43 PM

    instagram apk's Avatar
  23. 23 Posted by sunny on 23 Jun, 2016 11:57 AM

    sunny's Avatar

    good The Kodi App works extremely well to view on-line diverse request is normally totally prepared with Android and nice.

  24. 24 Posted by free store on 28 Jun, 2016 12:55 PM

    free store's Avatar
  25. 25 Posted by creehack apk on 28 Jun, 2016 01:38 PM

    creehack apk's Avatar
  26. 26 Posted by movietubeapk on 28 Jun, 2016 01:40 PM

    movietubeapk's Avatar
  27. 27 Posted by zapya apK on 28 Jun, 2016 01:41 PM

    zapya apK's Avatar
  28. 28 Posted by xender apk on 28 Jun, 2016 01:42 PM

    xender apk's Avatar
  29. 29 Posted by wifikill apk on 28 Jun, 2016 01:42 PM

    wifikill apk's Avatar
  30. 30 Posted by shareit apk on 28 Jun, 2016 01:43 PM

    shareit apk's Avatar

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac