Can PDO be escaped automatically?

Source: Internet
Author: User
A field in my database is saved in this way, {code ...} I wrote a backup program, and the exported format is correct {code ...} however, after the program is used to import the data to the database, the content of this field changes. It should be PDO that removed & #039; and linefeed, which led to my data... A field in my database is saved in this way,

Array (1 => array (\ 'id \ '=> 1, \ 'name \' => \ 'test \ ', \ 'desc \' => NULL, \ 'url \ '=> \ 'HTTP: // 163.com \', \ 'parent \ '=> 0 ,),)

I wrote a backup program and the exported format is correct.

Insert into 'table' VALUES ('names', 'array (1 => array (\ 'id \ '=> 1, \ 'name \ '=> \ 'test \', \ 'desc \ '=> NULL, \ 'url \' => \ 'HTTP: // 163.com \', \ 'parent \ '=> 0,),)', 'key ');

However, after the program is imported into the database, the content of this field changes. It should be that PDO has removed \ 'and linefeed, as a result, my data cannot be used again...

Array (1 => array ('id' => 1, 'name' => 'test', 'desc' => NULL, 'url' => 'HTTP: // 163.com ', 'parent' => 0 ,),)

Yes. In some cases, I don't want to use serialize or unserialize.

Reply content:

A field in my database is saved in this way,

Array (1 => array (\ 'id \ '=> 1, \ 'name \' => \ 'test \ ', \ 'desc \' => NULL, \ 'url \ '=> \ 'HTTP: // 163.com \', \ 'parent \ '=> 0 ,),)

I wrote a backup program and the exported format is correct.

Insert into 'table' VALUES ('names', 'array (1 => array (\ 'id \ '=> 1, \ 'name \ '=> \ 'test \', \ 'desc \ '=> NULL, \ 'url \' => \ 'HTTP: // 163.com \', \ 'parent \ '=> 0,),)', 'key ');

However, after the program is imported into the database, the content of this field changes. It should be that PDO has removed \ 'and linefeed, as a result, my data cannot be used again...

Array (1 => array ('id' => 1, 'name' => 'test', 'desc' => NULL, 'url' => 'HTTP: // 163.com ', 'parent' => 0 ,),)

Yes. In some cases, I don't want to use serialize or unserialize.

Ha ha ha ha. It's just a string. Unless you eval, security and performance are not as good as serialization. You can format the json format.

The default exec and query operations of PDO do not support filtering. 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.