PHP代码中的MySQL表名 [英] MySQL table names in PHP code

查看:84
本文介绍了PHP代码中的MySQL表名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习PHP和MySQL。在我使用的示例中,SQL表

名称是转义的。重音符号(`)标记,而不是单个或双重

报价。


任何人都可以解释一下吗?


例如,我有以下内容:


$ sql_command =" SELECT * from`7-1_List`" ;;


我尝试在php.net网站上四处寻找,但显然我没有使用

正确的搜索条件。


我在问,我想我已经弄清楚双引号(")

与单引号('')有什么不同,但是如果有讨论那么

有人可以请指出,那将是非常好的。


谢谢。

解决方案

sql_command =" SELECT *来自`7-1_List`" ;;


我试着在php.net网站上四处寻找,但显然我没有使用

正确的搜索条件。


虽然我在问,我想我已经弄清楚双引号(")

与单一的不同之处测试(''),但是如果有讨论说

有人可以指点我,那就太好了。


谢谢。


MikeB写道:


我正在学习PHP和MySQL。在我使用的示例中,SQL表

名称是转义的。重音符号(`)标记,而不是单个或双重

报价。


任何人都可以解释一下吗?


例如,我有以下内容:


sql_command =" SELECT * from'7-1_List`" ;;


我试着在php.net网站上四处寻找,但显然我没有使用

正确的搜索条件。


虽然我在问,但我想我已经弄清楚双引号(")

与单引号('')有什么不同,但如果有讨论那么

有人可以指点我,那将是非常好的。


谢谢。



那是因为它是MySQL惯例而与PHP无关。

试试MySQL文档。 />

SQL命令只是PHP传递给数据库的字符串。从那里开始,这是数据库的责任。


-

======== ==========

删除x来自我的电子邮件地址

Jerry Stuckle

JDS计算机培训公司
js ******* @ attglobal.net

==================


I''m learning PHP and MySQL. In the samples I work with, the SQL table
names are "escaped" in accent grave (`) marks, not in single or double
quotes.

Can anyone explain that?

For instance, I have the following:

$sql_command = "SELECT * from `7-1_List`";

I tried looking around on the php.net site, but clearly I''m not using
the right search terms.

While I''m asking, I think I''ve figured out how double quotes (")
differ from single quotes (''), but if there is a discussion that
someone can point me to, that would be very nice.

Thanks.

解决方案

sql_command = "SELECT * from `7-1_List`";

I tried looking around on the php.net site, but clearly I''m not using
the right search terms.

While I''m asking, I think I''ve figured out how double quotes (")
differ from single quotes (''), but if there is a discussion that
someone can point me to, that would be very nice.

Thanks.


MikeB wrote:

I''m learning PHP and MySQL. In the samples I work with, the SQL table
names are "escaped" in accent grave (`) marks, not in single or double
quotes.

Can anyone explain that?

For instance, I have the following:


sql_command = "SELECT * from `7-1_List`";

I tried looking around on the php.net site, but clearly I''m not using
the right search terms.

While I''m asking, I think I''ve figured out how double quotes (")
differ from single quotes (''), but if there is a discussion that
someone can point me to, that would be very nice.

Thanks.

That''s because it''s a MySQL convention and has nothing to do with PHP.
Try the MySQL documentation.

SQL commands are just strings PHP passes to the database. From there
on, it''s the databases responsibility.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================


这篇关于PHP代码中的MySQL表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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