MySQL-Ask the great God: Php using Medoo cannot insert JSON into the database?

Source: Internet
Author: User

  
    10                

内容

) */ //not work $database->insert("test",$arr); //It work $database->insert("test",[ "UUID" => $arr['UUID'], "content" => $arr['content'] ]); }

Just contacted PHP soon, Google for a long time did not know why, very depressed. I hope the great God can answer, thank you

Reply content:


  
    10                

内容

) */ //not work $database->insert("test",$arr); //It work $database->insert("test",[ "UUID" => $arr['UUID'], "content" => $arr['content'] ]); }

Just contacted PHP soon, Google for a long time did not know why, very depressed. I hope the great God can answer, thank you

MySQL does not support directly into the array form, you want to save in JSON format, you have to json_encode the array, a JSON string to save to the database

MySQL cannot store an array object. You have to convert the string into JSON format or other format. By the way, when you add true to Json_decode (), a JSON string is converted to an array object.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.