Joomla 数据库查询 SELECT AS [英] Joomla database query SELECT AS
本文介绍了Joomla 数据库查询 SELECT AS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我只是假设能够查询我的假设数据库:
So I'm just hypothetically thrilled to be querying my hypothetical database:
$query->select($db->quoteName(array('user_id', 'name')));
但是,我希望查询看起来像:
I would, however, like the query to look like:
SELECT `user_id` AS `uid`, `name` AS `User-Name`
我到底是怎么把 AS 弄进去的?
How the heck do I get the AS in there?
推荐答案
我知道这个问题已经问了 6 个月了,所以您可能已经找到了答案或解决了这个问题,但对于遇到类似问题的其他人来说:
I know this question is 6 months old, so you've probably found an answer or worked around it, but for anyone else who has a similar problem:
$query->select($db->quoteName(array('user_id','name'),array('uid','User-Name')));
如果您只想为某些字段使用别名,只需在数组中为您不想别名的字段传递null
,例如:
If you only want to use an alias for some fields, just pass null
in the array for the fields you don't want to alias, so for example:
$query->select($db->quoteName(array('user_id','name'),array(null,'User-Name')));
愿意
"SELECT `user_id`, `name` AS `User-Name`"
这篇关于Joomla 数据库查询 SELECT AS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文