在Perl中,MySQL数据库输入的转义字符串相当于什么?

Dir*_*irk 4 mysql perl

在Perl中,MySql数据库输入的转义字符串相当于什么?

引用最好的方式?

ber*_*nie 10

您可以使用DBI 占位符.

这是一个例子(来自此链接):

#! /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 );
Run Code Online (Sandbox Code Playgroud)