cfquery to array

Discussion in 'Programming' started by forumposters, Mar 21, 2007.

  1. #1
    How would you populate an array from a query?
     
    forumposters, Mar 21, 2007 IP
  2. datropics

    datropics Peon

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Here's is one way you could do it:

    <cfquery name="Yada" ....>
    select FieldName1, fieldName2, FieldName3 from Table Where condition order by Sort
    </cfquery>

    <cfset AllOfField1 = ValueList(Yada.FieldName1,",")>
    <cfset Field1Array = ListToArray(AllOfField1)>


    HTH
     
    datropics, Mar 24, 2007 IP
  3. forumposters

    forumposters Peon

    Messages:
    270
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Are there any user defined functions out there to do this all in one step rather than two?
     
    forumposters, Mar 27, 2007 IP
  4. datropics

    datropics Peon

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Well you could in fact do this:

    <cfset FieldIArray = ListToArray(ValueList(Yada.FieldName1,","))>

    HTH
     
    datropics, Mar 27, 2007 IP