Could some tell me if there is a function which works the same as PHP's mysql_real_escape_string()
for Perl from the DBI module?
相关问题
- $ENV{$variable} in perl
- Is it possible to pass command-line arguments to @
- Redirecting STDOUT and STDERR to a file, except fo
- Change first key of multi-dimensional Hash in perl
- How do I get a filehandle from the command line?
相关文章
- Running a perl script on windows without extension
- Comparing speed of non-matching regexp
- Can NOT List directory including space using Perl
- Extracting columns from text file using Perl one-l
- Lazy (ungreedy) matching multiple groups using reg
- How do I tell DBD::mysql where mysql.sock is?
- What is a good way to deploy a Perl application?
- Speeding up Selenium Webdriver
From http://www.stonehenge.com/merlyn/UnixReview/col58.html :
Don't. Escape. SQL.
Don't. Quote. SQL.
Use SQL placeholders/parameters (
?
). The structure of the SQL statement and the data values represented by the placeholders are sent to the database completely separately, so (barring a bug in the database engine or the DBD module) there is absolutely no way that the data values can be interpreted as SQL commands.As a side benefit, using placeholders is also more efficient if you re-use your SQL statement (it only needs to be prepared once) and no less efficient if you don't (if you don't call prepare explicitly, it still gets called implicitly before the query is executed).
You should use placeholders and bind values.
Like quote?
I would also recommend reading the documentation for DBD::MySQL if you are worried about utf8.
Database Handle Method "quote"
http://metacpan.org/pod/DBI#quote