这是一个类似的问题,这个“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?
从documentation:
此功能允许重复使用的命令只被解析和计划一次,而不是每次执行时.
见pg_prepare
上面链接的页面示例:
<?PHP
// Connect to a database named "mary"
$dbconn = pg_connect("dbname=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很好地回答了以下问题:
>为什么使用准备好的陈述 >什么时候应该准备好 声明? (编辑:北几岛)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|