您的位置:首页 > 编程语言 > PHP开发

php推荐使用的文件名声明与SQL的基本语句汇总

2016-12-23 09:26 447 查看
常用部分名称:仅供参考

日常开发中,可以用一下的英文来为PHP文件声明,这样看起来会规范一点,适合初学者参考!!!

 id 主键数据表中使用

 cid 分类id(fid)

 pid 父级id

 uid 用户id

 user   用户(userInfo用户信息)

 username 用户名(uname)

 password 密码

 login  登录

 logout 退出

 register 注册 reg

 title 标题

 keyword 关键字

 content  内容

 sex  性别

 email 邮箱

 tel  电话

 status 状态

 addr  地址

 province 省

 city  城市

 area  地区

 type 类型

 comment  评论

 product   产品

 news      新闻

 category  分类

 orders    订单

 price   价格

 number  数量(num)

 total   总计

 goods     产品

 sn        编号

 brand   品牌

 size    大小/尺寸

 hot    热门

 best   精品

 new    新品

 pay     支付

 logo    网站logo

 search  搜索

 thumb   缩略图

 set  设置(开头setName)

 get  取值(开头getName)

 add    添加(开头addNews)

 edit   编辑(开头editNews)

 del    删除(开头delNews)

 info  信息

 upload 上传(uploadFile/uploadImage)

 config  配置

 admin  管理员

 banner  横幅广告

 links   友情链接

 reply  回复

 path 路径

 tmp  临时变量(temp)

 demo 演示 例子

 shop  商城 mall

 bbs  论坛

 meun 菜单

 send 发送

 save 保存

 

  SQL基本语句:增 删 改 查(curd)

user 为数据库里面的表

  1.查询语句(select)

   1)简单查询

     select * from user

   2)查询指定字段

     select id,username from user

   3)别名查询

     select id,username AS name from user

   4)条件查询 (=/<>/>/>=/</<= )

     select * from user where id=103 

     select * from user where id<>103

     select * from user where id>103

     select * from user where username='abc' and password=md5('123456')

      ........................

   5)in条件查询 查询id等于 1,10,103,104

     select * from user where id in(1,10,103,104)

   6)like模糊查询 %*% 前后匹配

    select * from user where username like '%er%'

   7)between and 范围查询

    select * from user where id between 1 and 100

   8)多个条件 and or 链接

   select * from user where id>100 and sex=1 and tel like '%7819' and email like 'a%'

   9)排序 desc(从大到小) asc(从小到大)

   

   select * from user where id between 1 and 100 order by id desc

   select * from user  order by tel asc,id desc

   10)获取多少行数据

   

    select * from user where id>1 order by id desc;

    select * from user where id>1 order by id desc limit 0,3;

    select * from user where id>1 order by id desc limit 3,3;

    select * from user where id>1 order by id desc limit 6,3;

   11)统计查询

     

    select count(*) as num from user

    

    扩展函数:

    

     select min(id) from user 最小值   

     select max(id) from user 最大值 

     select sum(id) from user 累计值 

     select avg(id) from user 平均数 

  2.插入语句

    insert into user(username,password[,....]) values('abc','123456'[,....])

   

  3.更新语句

    update user set username='def',password=md5('123456')[,....] where id=10

  4.删除

   delete from user where id=1; 删除单条

   delete from user where id in(1,2,3,4[,.....]);一次删除多条

 

  

  

   

     

  

 

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: