The variable name or array position IS the 'query name' in the context
you're asking, specifically it's a reference to the query data contained
therein.  However, if I'm understanding your underlying need and assuming
you've populated an array with a number of queries and you need to
programmatically determine the 'original' name of the query, you should
consider tracking those names either by always making the first array
position be a struct of query names/array positions which you can
reference, or you could do something as simple as include a column alias in
every query so you can check it inline, like so:

<cfquery name="qFoobar" ...>
SELECT 'qFoobar' AS queryName, mytable.*
FROM mytable
</cfquery>

<cfset arrayappend(myQueryArray,qFoobar)>

Then you could get the queryname by simply getting
myQueryArray[3].queryName[1] .  Note this will only work if the query
contains at least one row, and for that reason the other suggestion of
using the array's first position to hold a tracking struct is superior.
Again, this is all making assumptions about what problem you're actually
trying to solve.

Kevin



On Tue, Jul 10, 2012 at 6:45 PM, Alex Skinner <[email protected]> wrote:

> I think what he's asking is how can i find out the name of my query
>
> so given
>
> <cfquery name="qFoobar" datasource="myds">
> Select 1
> </cfquery>
>
> <cfset myArray[3]=qFooBar>
>
> How would you on myArray[3] be able to work out that the query name was
> qFoobar.
>
> Personally I've no idea, and I think it would depend on how the query was
> made.
>
> cfdirectory, cfpop, queryNew(), cfquery, cfstoredproc, cfsearch etc
>
> Cheers
>
> Alex
>
>
>
> On 10 July 2012 16:42, Jeff Lucido <[email protected]> wrote:
>
>> I am a little lost here with your specific question. Are you asking
>> for the query column name for a specific query resultset at a
>> particular row (in your example row '3')? If this is the case, how
>> would you not know the query column names? There are functions which
>> will give you all the data for a specific query column either as a
>> list or an array (queryColumnArray() or queryColumnList()).
>>
>> One last thought, if you are looking for the value of a specific query
>> column and row combination then your would refer to this data as:
>> myQueyName['myColumnName'][rowIdx]
>>
>> Hope this helps a little. If not, clarify your message a little
>> further and I will be glad to help.
>>
>> Good luck,
>> -JSLucido
>>
>> On Tue, Jul 10, 2012 at 9:21 AM, Matt C <[email protected]> wrote:
>> > Is there any way to take a query object that is stored in a variable
>> (or an
>> > array position) and retrieve the query's name?  I'm quite surprised I
>> > couldn't just say "myQryArray[3].name".
>> >
>> > --
>> > online documentation: http://openbd.org/manual/
>> > http://groups.google.com/group/openbd?hl=en
>>
>> --
>> online documentation: http://openbd.org/manual/
>>  http://groups.google.com/group/openbd?hl=en
>>
>
>
>
> --
> Alex Skinner
> Managing Director
> Pixl8 Interactive
>
> Tel: +448452600726
> Email: [email protected]
> Web: pixl8.co.uk
>
>
>  --
> online documentation: http://openbd.org/manual/
> http://groups.google.com/group/openbd?hl=en
>

-- 
online documentation: http://openbd.org/manual/
 http://groups.google.com/group/openbd?hl=en

Reply via email to