PDO quote method

后端 未结 4 2132
时光说笑
时光说笑 2020-12-06 01:32

Where and when do you use the quote method in PDO? I\'m asking this in the light of the fact that in PDO, all quoting is done by the PDO object therefore no user input shoul

4条回答
  •  被撕碎了的回忆
    2020-12-06 02:10

    A bit late anwser, but one situation where its useful is if you get a load of data out of your table which you're going to put back in later.

    for example, i have a function which gets a load of text out of a table and writes it to a file. that text might later be inserted into another table. the quote() method makes all the quotes safe.

    it's real easy:

    $safeTextToFile = $DBH->quote($textFromDataBase); 
    

提交回复
热议问题