这是一个类似的问题,这个“When not to use Prepared statements?”,但与“如何”部分和Postgresql.
我知道我需要准备好的语句,因为我在一个脚本中对数据库进行了多次调用.
我想得到关于following sentence的具体例子
Look at typecasting, validating and sanitizing variables and using PDO with prepared statements.
通过验证和消毒变量,我知道他的意思.但是,我并不完全确定准备好的陈述.我们如何准备陈述?通过过滤器,即通过消毒?或者通过一些PDO层?层的定义是什么?
准备好的陈述在声明中意味着什么?请使用具体的例子.
解决方法:
What do prepared statements mean in
the statement?
此功能允许重复使用的命令只被解析和计划一次,而不是每次执行时.
<?PHP
// Connect to a database named "mary"
$dbconn = pg_connect("@R_502_6417@ame=mary");
// Prepare a query for execution
$result = pg_prepare($dbconn, "my_query", 'SELECT * FROM shops WHERE name = $1');
// Execute the prepared query. Note that it is not necessary to escape
// the string "Joe's Widgets" in any way
$result = pg_execute($dbconn, "my_query", array("Joe's Widgets"));
// Execute the same prepared query, this time with a different parameter
$result = pg_execute($dbconn, "my_query", array("Clothes Clothes Clothes"));
?>
MySQL documentation for Prepared Statements很好地回答了以下问题:
>为什么使用准备好的陈述
>什么时候应该准备好
声明?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。