我正在尝试在 ColdFusion 中创建一个脚本,该脚本通过使用以下查询来检测指定用户是否存在查询:
// User one is defined by the current session
<cfquery name = "Friendship" datasource = "#DSN#">
SELECT *
FROM `conversations`
WHERE `user_one` LIKE '#user.id#'
ORDER by id ASC
</cfquery>
<cfquery name = "FriendshipToUsername" datasource = "#DSN#">
SELECT *
FROM users
WHERE id = '#user_two#'
ORDER BY id DESC
</cfquery>
但是,当此查询没有结果时,我想使用以下查询:
<cfquery name = "Friendship" datasource = "#DSN#">
SELECT *
FROM `conversations`
WHERE `user_two` LIKE '#user.id#'
ORDER by id ASC
</cfquery>
<cfquery name = "FriendshipToUsername" datasource = "#DSN#">
SELECT *
FROM users
WHERE id = '#user_one#'
ORDER BY id DESC
</cfquery>
在 ColdFusion 中可以做到这一点吗?我想以这种方式保留查询的名称,否则我将需要更改我的整个站点。这是我页面的代码,如果您需要它:
<cfif IsDefined("FriendshipToUsername.username")>
<div class="person">
<div class="avatar">
<div style="z-index:1;width: 64px; height: 73px; margin-bottom:-20px; margin-top:-30px; float: right; background: url(http://habbo.it/habbo-imaging/avatarimage?figure=#FriendshipToUsername.look#&action=wav&direction=3&head_direction=3&gesture=srp&size=b&img_format=gif);"></div>
</div>
<div class="info">
<a href="chat.cfm?chat=#Friendship.id#" style="text-decoration: none; color: ##4b4b4b;"> <h3>#FriendshipToUsername.username#</h3></a>
<a href="chat.cfm?chat=#Friendship.id#" style="text-decoration: none; color: ##4b4b4b;"><p>#FriendshipToUsername.motto#</p></a>
<p>Laatst gezien: gisteren</p></a>
</div>
</div>
</cfif>
提前致谢!