Home Backend Development PHP Tutorial SQL查询中的{}是干什么的?该如何处理

SQL查询中的{}是干什么的?该如何处理

Jun 13, 2016 am 11:06 AM
nbsp select sql where

SQL查询中的{}是干什么的?
$sqlstr="select name from user where id='{$row[0]}'";

我同学写的代码,请问里边的{}起到什么作用了?

多谢~~
------解决方案--------------------
在""表示的字符串中,用{变量}来表示引用一个变量的值,当然实际上大部分情况下不加大括号也能正常使用,不过加上大括号是个很好的习惯
------解决方案--------------------
被花括号“{}”括起的内容表示是一个整体
凡是有可能出现歧义的地方都应该用花括号“{}”括起
比如你示例的代码中、条件语句分支中的多行代码,等等
------解决方案--------------------
{} 其实就是一个区块,一个整体.
------解决方案--------------------
 就是声明这是一个变量,因为有时候“”和‘’混排会出错,这样避免了
------解决方案--------------------
这个基本都是用于包围变量的,能安全的让变量在字符串中当真正的变量来用
------解决方案--------------------
这跟SQL没关系的,作用楼上各位都解释了
------解决方案--------------------
貌似没有多少关系。
------解决方案--------------------
区别不大,一个是不戴安全帽修房子,一个是戴着安全帽修房子!!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Solution: Your organization requires you to change your PIN Solution: Your organization requires you to change your PIN Oct 04, 2023 pm 05:45 PM

Solution: Your organization requires you to change your PIN

What is the difference between HQL and SQL in Hibernate framework? What is the difference between HQL and SQL in Hibernate framework? Apr 17, 2024 pm 02:57 PM

What is the difference between HQL and SQL in Hibernate framework?

10 Ways to Adjust Brightness on Windows 11 10 Ways to Adjust Brightness on Windows 11 Dec 18, 2023 pm 02:21 PM

10 Ways to Adjust Brightness on Windows 11

How to turn off private browsing authentication for iPhone in Safari? How to turn off private browsing authentication for iPhone in Safari? Nov 29, 2023 pm 11:21 PM

How to turn off private browsing authentication for iPhone in Safari?

Win10/11 digital activation script MAS version 2.2 re-supports digital activation Win10/11 digital activation script MAS version 2.2 re-supports digital activation Oct 16, 2023 am 08:13 AM

Win10/11 digital activation script MAS version 2.2 re-supports digital activation

Usage of division operation in Oracle SQL Usage of division operation in Oracle SQL Mar 10, 2024 pm 03:06 PM

Usage of division operation in Oracle SQL

What does the identity attribute in SQL mean? What does the identity attribute in SQL mean? Feb 19, 2024 am 11:24 AM

What does the identity attribute in SQL mean?

Comparison and differences of SQL syntax between Oracle and DB2 Comparison and differences of SQL syntax between Oracle and DB2 Mar 11, 2024 pm 12:09 PM

Comparison and differences of SQL syntax between Oracle and DB2

See all articles