Matt Hall-Smith
Wed, 29 Nov 2006 12:47:53 -0800
Thanks Bayo, for clearing that one up for us.
_____
From: [EMAIL PROTECTED] [EMAIL PROTECTED] On
Behalf Of bayo
Sent: Wednesday, 29 November 2006 6:32 p.m.
To: reactor@doughughes.net
Subject: Re: [Reactor for CF] How to reset getWhere() in an iterator ?
Matt,
With the lines
<cfset
r_Company.getAttributeIterator().getWhere().isEqual('CompanyAttribute','comp
anyID',3854)>
<cfset
r_Company.getAttributeIterator().getWhere().isEqual('Attribute','AttributeTy
peID',5)>
you are effectively adding 2 whereCommands to a single where object. So in
SQL terms your where clause looks like
'where companyId = 3854 and attributeTypeID = 5'
Ater this, when you call
<cfset r_Company.getAttributeIterator().resetwhere()>
the r_Company iterator gets assigned a new where object instance. In SQL
terms, all the conditionals in the where clause are cleared. In addition,
the array of record objects and the query results that back the iterator are
cleared.
Ok, so far.
With
<cfset
r_Company.getAttributeIterator().getWhere().isEqual('Attribute','AttributeTy
peID',5)>
followed by
<cfset r_Company.getAttributeIterator().reset()>
followed by
<cfset
r_Company.getAttributeIterator().getWhere().isEqual('Attribute','AttributeTy
peID',6)>
the where object held by the queryObject (which is in turn held by the
r_Company iterator) is the same one for both calls to isEqual(). This means
that you presently have an iterator with a where clause that looks like
'where attributeId = 5 and attributeId = 6'
...which will always return 0 records.
Bayo
----- Original Message ----
From: Matt Hall-Smith <[EMAIL PROTECTED]>
To: reactor@doughughes.net
Sent: Tuesday, November 28, 2006 8:11:51 PM
Subject: [Reactor for CF] How to reset getWhere() in an iterator ?
Hello again,
Looking for guidance on the correct way to reset getWhere on an iterator ...
(On latest build via svn)
This (I think) should work, but my comments show that after the first
getWhere and a reset subsequent calls *append* the successive getWhere
statements causing q_AttrTwo and q_AttrThree to return zero records in the
3rd and 4th query.
<cfset r_Company = Reactor.CreateRecord("COMPANY").load(CompanyID=3854)>
<cfset q_iterator = r_Company.getAttributeIterator().getQuery()>
<cfdump var="#q_iterator#"> <!--- 12 Attributes returned --->
<!--- attempt to get AttrOne -->
<cfset
r_Company.getAttributeIterator().getWhere().isEqual('Attribute','AttributeTy
peID',5)>
<cfset q_AttrOne = r_Company.getAttributeIterator().getQuery()>
<cfdump var="#q_AttrOne#"> <!--- 1 Attribute returned, fires OK--->
<!--- reset backing query etc, and attempt to get AttrTwo-->
<cfset r_Company.getAttributeIterator().reset()>
<cfset
r_Company.getAttributeIterator().getWhere().isEqual('Attribute','AttributeTy
peID',6)>
<cfset q_AttrTwo = r_Company.getAttributeIterator().getQuery()>
<cfdump var="#q_AttrTwo#"> <!--- 0 records returned, should be 1 --->
<!--- reset backing query etc, and attempt to get AttrThree -->
<cfset r_Company.getAttributeIterator().reset()>
<cfset
r_Company.getAttributeIterator().getWhere().isEqual('Attribute','AttributeTy
peID',4)>
<cfset q_AttrThree = r_Company.getAttributeIterator().getQuery()>
<cfdump var="#q_AttrThree#"> <!--- 0 records returned, should be 1--->
This works (explicit resetwhere(), then 2 x GetWhere's to get where I want
to be) :
<cfset r_Company = Reactor.CreateRecord("COMPANY").load(CompanyID=3854)>
<cfset q_iterator = r_Company.getAttributeIterator().getQuery()>
<cfdump var="#q_iterator#"> <!--- 12 Attributes returned --->
<cfset
r_Company.getAttributeIterator().getWhere().isEqual('CompanyAttribute','comp
anyID',3854)>
<cfset
r_Company.getAttributeIterator().getWhere().isEqual('Attribute','AttributeTy
peID',5)>
<cfset q_AttrOne = r_Company.getAttributeIterator().getQuery()>
<cfdump var="#q_AttrOne#"> <!--- 1 Attribute returned, fantastic --->
<cfset r_Company.getAttributeIterator().resetwhere()>
<cfset
r_Company.getAttributeIterator().getWhere().isEqual('CompanyAttribute','comp
anyID',3854)>
<cfset
r_Company.getAttributeIterator().getWhere().isEqual('Attribute','AttributeTy
peID',6)>
<cfset q_AttrTwo = r_Company.getAttributeIterator().getQuery()>
<cfdump var="#q_AttrTwo#"> <!--- 1 Attribute returned, you beauty --->
<cfset r_Company.getAttributeIterator().resetwhere()>
<cfset
r_Company.getAttributeIterator().getWhere().isEqual('CompanyAttribute','comp
anyID',3854)>
<cfset
r_Company.getAttributeIterator().getWhere().isEqual('Attribute','AttributeTy
peID',4)>
<cfset q_AttrThree = r_Company.getAttributeIterator().getQuery()>
<cfdump var="#q_AttrThree#"> <!--- 1 Attribute returned, hola --->
Should method 1 work or am I misiterpreting what reset() actually does ?
Cheers,
Matt
Pauaware Information Architects
Live data on demand
www.pauaware.co.nz <http://www.pauaware.co.nz/>
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Reactor for ColdFusion Mailing List
reactor@doughughes.net
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
Reactor for ColdFusion Mailing List
reactor@doughughes.net
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
reactor@doughughes.net
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --