Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个如下所示的 sql 查询
select id from table where name like 'somename';
现在 db 中只有一条记录。现在绑定,sql查询如下
my $sth = $dbh->prepare("select id from table where name=?"); $sth->execute('somename'); .... # fetch single row from array
那么哪个更好呢?单行绑定或不绑定?
是的。原因很简单 - 使用占位符是个好主意,甚至将它用于单个参数也是一种很好的做法。一段时间后,你的手会不假思索地使用占位符。