Can PDO not be automatically escaped?

Source: Internet
Author: User
There's a field in my database that's saved,

array (  1 =>       array (        \'id\' => 1,        \'name\' => \'测试\',        \'desc\' => NULL,        \'url\' => \'http://163.com\',        \'parent\' => 0,      ),)       

Write a backup of the program, export the format is not wrong

INSERT INTO `table` VALUES('names','array (  1 =>       array (        \'id\' => 1,        \'name\' => \'测试\',        \'desc\' => NULL,        \'url\' => \'http://163.com\',        \'parent\' => 0,      ), )','key');

However, after the program was imported into the database, the contents of this field changed, it should be PDO to remove the \ ', also removed the line break, resulting in my data can not be used again ...

array (  1 =>   array (    'id' => 1,    'name' => '测试',    'desc' => NULL,   'url' => 'http://163.com',    'parent' => 0,  ),)

Well, because of some circumstances, I don't want to use serialize and unserialize.

Reply content:

There's a field in my database that's saved,

array (  1 =>       array (        \'id\' => 1,        \'name\' => \'测试\',        \'desc\' => NULL,        \'url\' => \'http://163.com\',        \'parent\' => 0,      ),)       

Write a backup of the program, export the format is not wrong

INSERT INTO `table` VALUES('names','array (  1 =>       array (        \'id\' => 1,        \'name\' => \'测试\',        \'desc\' => NULL,        \'url\' => \'http://163.com\',        \'parent\' => 0,      ), )','key');

However, after the program was imported into the database, the contents of this field changed, it should be PDO to remove the \ ', also removed the line break, resulting in my data can not be used again ...

array (  1 =>   array (    'id' => 1,    'name' => '测试',    'desc' => NULL,   'url' => 'http://163.com',    'parent' => 0,  ),)

Well, because of some circumstances, I don't want to use serialize and unserialize.

Oh oh ha ha ha ha ha Oh, first of all, you appear to have directly stored the array in, actually take out to simply can not use. It's just a string. Unless you eval, security and performance are not as serializable. Even if your JSON format is OK.

The default exec and query for PDO does not support filtering. Please use prepare

  • 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.