Perl中MySql数据库输入的转义字符串相当于什么?
引用最好的方法吗?
答案 0 :(得分:10)
您可以使用DBI placeholders。
以下是一个示例(来自this link):
#! /usr/bin/perl
use DBI;
print "Enter the city you live in: ";
chomp( $city = <STDIN> );
print "Enter the state you live in: ";
chomp( $state = <STDIN> );
$dbh = DBI->connect(your db info here);
$sth = $dbh->prepare( "SELECT name WHERE city = ? AND state = ?" );
$sth->execute( $city, $state );