Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

understanding application variables

Community Beginner ,
Apr 23, 2011 Apr 23, 2011

I'm getting started with Coldfusion and making some tests with application variables.

I am not understanding the way coldfusion update values of application variables.

For example

<cfparam name="application.userList" type="string" default=""> <cfif listLen(application.userList) eq 0> <cfquery name="getUsers"> SELECT * FROM members </cfquery> <cfset application.userList = valueList(getUsers.username)> </cfif> <cfoutput>#application.userList#</cfoutput>

ok I get the following output

username1, username2,username3...

Then I added a record into database and I run the same above code.

Does Coldfusion allow to update the value of an application variable at runtime ?

Why application.userList does not update ?

Any suggestion is much appreciated !

TOPICS
Getting started
492
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 23, 2011 Apr 23, 2011

Filippo Lughi wrote:

Then I added a record into database and I run the same above code.

Does Coldfusion allow to update the value of an application variable at runtime ?

Why application.userList does not update ?

Yes application variables are updateable at runtime.  Your code is doing just that.  The only thing special about application variables is that they are global to ALL cfml templates running under the same application name on the same ColdFusion server.

Why your application.userList does not update, would be a question about your database.  Because there is nothing in your CFML code that would prevent it.  The first two database questions to ask are:

1) Are you updating the same database that ColdFusion is connected to and from which it is reading its data?

2) Are you COMMITTING the data update with whatever method you might be using to insert the new records?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 23, 2011 Apr 23, 2011
LATEST

1) yes

2) yes

ops I forgot to take off the if statement

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 23, 2011 Apr 23, 2011

Well... after the first request, in which you set application.userlist to be [whatever]... will listlen(application.userList) equal zero (ie: your IF condition)?  No.

So once you set your application.userlist to [something], your code specifically prevents it being updated again.

Re-think your logic.

--

Adam

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources