|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
assigning something to a cfif outcome
Hi,
I was just wondering if osmeone can point me in the right direction in coldfusion/sql can you have something to equal the outcome of a if statement. E.G Code:
iL.languageID = <cfif (translator eq 1) AND (Currentsite IS NOT NULL) AND (bOnPage eq 0)> filterLanguage <cfelse> s.defaultLanguage </cfif> Thanks for your help Andy |
|
#2
|
|||
|
|||
|
try
<cfif a = b> <cfset myvar = 1> <cfelse> <cfset myvar = 2> </cfif> then use myvar anywhere in the code |
|
#3
|
|||
|
|||
|
IIf function
In addition to CfFreelancer's code, you can also say:
Code:
<cfset il.LanguageID =
Iif((Translator IS 1) AND (CurrentSite IS NOT NULL) AND (bOnPage IS 0),
DE(filterLanguage),
DE(s.defaultLanguage))>
|
|
#4
|
|||
|
|||
|
Actually, iif() is significantly slower than <cfif>. When you combine that with the unreadability, I recommend against using it.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#5
|
|||
|
|||
|
Thanks kiteless
- I just always assumed a function would be faster. Live and learn, as they say! |
|
#6
|
|||
|
|||
|
Happy to help.
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > assigning something to a cfif outcome |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|