Cfdirectory Issue

Discussion in 'Programming' started by partyball, May 14, 2009.

  1. #1
    I want to say thanks in advance for any help. I have searched the many cfdirectory results and can not get what I need.

    I am doing a simple CFDIRECTORY tag. See below.
    <cfdirectory directory="MyDirectory\Statements\" action="list" name="Get_Statements" filter="*.pdf" recurse="no">

    Then I am making a query of the directory list.
    <cfquery name="dbQuery" dbtype="query">
    SELECT * FROM Get_Statements
    </cfquery>
    <cfdump var="#dbQuery#">

    My dump gives me the correct results.

    Now I am doing a query to get only the files I need out of the CFDIRECTORY results.
    <cfquery name="qoq" dbtype="query">
    SELECT * FROM dbQuery
    WHERE '#SESSION.auth.Owner#' IN ('#Get_Statements.name#')
    </cfquery>
    <cfdump var="#qoq#">

    Here I dump the results, but only see the first file in the CFDIRECTORY. I should have multiple results. So this is the first part of my problem.

    Then I do the output.
    <cfloop query="qoq">
    <cfoutput><a href="#qoq.name#" target="_new">#qoq.name#</a><br>
    </cfoutput>
    </cfloop>
    Here I do not get any results at all.

    So, I have two issues on this. One, I am not getting the results from my query named "qoq". Two, I am not getting any output at all in my final output tag.

    Any help is greatly appreciated.
     
    partyball, May 14, 2009 IP
  2. partyball

    partyball Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I posted the above thread. I was really hoping to get some direction on this issue I am having.

    Any help is appreciated. I have been spinning my wheels for days. I have tried using "LIKE" comparisons. I have tried dumping the directory results into a database and querying from there, but all to no avail.

    Any help is greatly appreciated.
     
    partyball, May 17, 2009 IP
  3. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    partyball,

    We'd love to help, but I don't think we have enough information. A few comments:

    Then I am making a query of the directory list.

    It has nothing to do with your problem, but it is already a query. So you do not need that step.

    Here I dump the results, but only see the first file in the CFDIRECTORY. I should have multiple results.

    If the first query contains the correct data, but the QoQ does not, then the problem is your WHERE clause. But we can't really tell you what to change without knowing what values are in the query, the value of #SESSION.auth.Owner#, or how the two are related.

    Can you please:
    1) Post a dump of the first query (ie the correct data)
    2) Explain what #SESSION.auth.Owner# is and how it relates to the files
    3) Give a specific example of the expected versus actual results:

    ie The results contain "file1.pdf", but I expect them to contain "file1.pdf", "file2.pdf", "file5.pdf" because of reason ..xyz...

    So, I have two issues on this. One, I am not getting the results from my query named "qoq". Two, I am not getting any output at all in my final output tag.

    That doesn't sound possible unless you are modifying "qoq" somehow, in between the <cfdump..> and the <cfloop> .
     
    cfStarlight, May 17, 2009 IP
  4. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    WHERE '#SESSION.auth.Owner#' IN ('#Get_Statements.name#')

    Also, this statement is very confusing. Ignoring the fact that #Get_Statements.name# only returns the value in the first row (because you are not inside a loop), why use #Get_Statements.name# at all?

    The query "dbQuery" is the same as "Get_Statements". So you already have access to the "name" column. I suspect what you are trying to do is more of a comparison. Like find all pdf's starting with the name 'Joe'. But that is just a guess:

    WHERE Upper(Name) LIKE '#SESSION.auth.Owner#%.pdf'
     
    cfStarlight, May 17, 2009 IP