Home > Backend Development > PHP Tutorial > thinkPHP的数据库操作怎么用alias?

thinkPHP的数据库操作怎么用alias?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 14:00:07
Original
1207 people have browsed it

连贯操作  作用                                      支持的参数类型 
alias        用于给当前数据表定义别名      字符串 

求助thinkPHP的操作方式alias怎么用,不要原生态的sql写法
thinkPHP的开发文档里面介绍是不是漏了alias的介绍?我的是thinkPHP3.1.2的开发文档


回复讨论(解决方案)

请遵守CSDN用户行为准则,不得违反国家法律法规。

http://www.thinkphp.cn/simple/quickstart_4.html

alias用于设置当前数据表的别名,便于使用其他的连贯操作例如join方法等。示例:$Model = M('User');$Model->alias('a')->join('__DEPT__ b ON b.user_id= a.id')->select();最终生成的SQL语句类似于:SELECT * FROM think_user a INNER JOIN think_dept b ON b.user_id= a.id
Copy after login
Copy after login
http://document.thinkphp.cn/manual_3_2.html#alias

alias用于设置当前数据表的别名,便于使用其他的连贯操作例如join方法等。示例:$Model = M('User');$Model->alias('a')->join('__DEPT__ b ON b.user_id= a.id')->select();最终生成的SQL语句类似于:SELECT * FROM think_user a INNER JOIN think_dept b ON b.user_id= a.id
Copy after login
Copy after login
http://document.thinkphp.cn/manual_3_2.html#alias
那类似于这种原生的sql 
select  count(*) from (select * from user  where userId >10) as a; 把一个查询结果集起别名为a ,再count计数a
这样的操作thinkPHP应该怎么写?

source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template