简体   繁体   English

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

[英]What's the equivalent of escaping strings for MySQL database input in Perl?

What's the equivalent of escaping strings for MySql database input in perl? 在perl中,MySql数据库输入的转义字符串相当于什么?

Is Quote the best way? 引用最好的方式?

You can use DBI placeholders . 您可以使用DBI 占位符

Here is an example (from 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 );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM