Skip to main content
February 15, 2009
Answered

Need to query array information -- more than 1D

  • February 15, 2009
  • 2 replies
  • 251 views
I'm writing a Facebook app, and want to compare my user db with some returned information from Facebook. I'm getting the correct info from FB, as an array with a structure inside it. It's not letting me use ArrayToList, so I'm assuming that's because of the structure.

When I use the code that's attached, it does loop through the data, and returns all the correct information.

What I am completely vaporlocked on is how to use the data returned from that loop to query against, as in:
SELECT foo
FROM bar
WHERE uid IN (loop of correct information)

I feel like this should be pretty damn easy, and it's making me want to poke my eyes out. Many thanks in advance, and please let me know if you need additional information.
    This topic has been closed for replies.
    Correct answer
    You rock like Satan. Many thanks. :D

    2 replies

    Inspiring
    February 16, 2009
    lusciousmango wrote:
    > I'm writing a Facebook app, and want to compare my user db with some returned
    > information from Facebook. I'm getting the correct info from FB, as an array
    > with a structure inside it. It's not letting me use ArrayToList, so I'm
    > assuming that's because of the structure.
    >
    > When I use the code that's attached, it does loop through the data, and
    > returns all the correct information.
    >
    > What I am completely vaporlocked on is how to use the data returned from that
    > loop to query against, as in:
    > SELECT foo
    > FROM bar
    > WHERE uid IN (loop of correct information)
    >
    > I feel like this should be pretty damn easy, and it's making me want to poke
    > my eyes out. Many thanks in advance, and please let me know if you need
    > additional information.
    >
    > The following code loops through the data returned by FB:
    >
    > <cfloop from="1" to="#arrayLen(crewGet)#" index="i" >
    > #crewGet .uid#<BR>
    > </cfloop>

    <!--- Create a list with the id's --->
    <cfset crewList = "">
    <cfloop from="1" to="#arrayLen(crewGet)#" index="i" >
    <cfset crewList = ListAppend(crewList, crewGet
    .uid)>
    </cfloop>


    <!--- Use the list you just created to get information from your
    database --->
    <cfquery>
    SELECT foo
    FROM bar
    WHERE uid IN (<cfqueryparam cfsqltype="cf_sql_integer"
    value="#crewList#" list="true">)
    </cfquery>

    --
    Mack
    Correct answer
    February 17, 2009
    You rock like Satan. Many thanks. :D
    Inspiring
    February 15, 2009
    When looping through your data, use the listfind function and some if/else logic to simulate the query.