$ _POST和构建SQL字符串 [英] $_POST and Building SQL Strings

查看:72
本文介绍了$ _POST和构建SQL字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部:


我是一名长期开发人员,不熟悉PHP ....


是否使用了成语在PHP中从$ _POST构建SQL语句

数据?


用于构建SQL语句。当然,我们可以做到以下几点:


$ email = $ _POST [''email'']

$ sql =" insert ... values (''$ email'')..."


但是,从$ _POST数组中提取每个变量似乎是尴尬。

尴尬。


构造字符串的问题来自于你经常需要在SQL语句中引用字符串的事实,例如,$ sql =

" insert ... values(''$ _ POST [''email''] ..)"似乎没有单引号和双引号的组合工作。


是否存在人们倾向于从中构建SQL字符串的标准方式$ _POST
PHP中的
(或$ _GET)数据?


谢谢,

John

jpuopolo

All:

I''m a long-time developer, new to PHP....

Is there an idiom used in PHP to construct SQL statments from $_POST
data?

I would guess that in many applications, the data read from $_POST are
used to build SQL statements. Certainly, we can do the following:

$email = $_POST[''email'']
$sql = "insert ... values (''$email'')..."

However, pulling out each variable from the $_POST array seems
awkward.

The problem with constructing a string comes in due to the fact that
you often need to quote strings in the SQL statement, e.g, $sql =
"insert...values(''$_POST[''email'']..)" There doesn''t seems to be a
combination of single and double quotes that work.

Is there a standard way people tend to build SQL strings from $_POST
(or $_GET) data in PHP?

Thanks,
John
jpuopolo

推荐答案

_POST

数据?


我我想在许多应用程序中,从
_POST
data?

I would guess that in many applications, the data read from


_POST读取的数据是用于构建SQL语句的
。当然,我们可以做到以下几点:

_POST are
used to build SQL statements. Certainly, we can do the following:


email =


这篇关于$ _POST和构建SQL字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆