When I run the following .hasMore() / .getNext() loop, it will end up
skipping every other record. If I specify to delete 1,2,3,4 as the
example shows, it will only delete 1 & 3. This makes me believe that I'm
somehow triggering .getNext() twice during each loop. Is there a better
way to access the record attributes returned from Iterator.getNext()
without advancing to the next record until I loop around again?

 

Sample Code:

<cfparam name="FORM.photosToDelete" default="1,2,3,4"> <!--- Delete
photos 1 through 4 --->

 

<cfset photos = article.getPhotoIterator()>

<!--- Assume that photo records 1 through 4 are the only ones associated
with this article record through the Iterator and are returned with full
attributes --->

 

<cfloop condition="photos.hasMore() IS TRUE">

            <cfset thisPhoto = photos.getNext()>

 

            <cfif listContains(FORM.photosToDelete, thisPhoto.getID())>

                        <cffile action="delete"
file="#thisPhoto.getPath()#">

                        <cffile action="delete"
file="#thisPhoto.getThumbnailPath()#">

                        <cfset thisPhoto.delete()>

            </cfif>

 

</cfloop>

 

I've read through the Iterator source code, and the Iterator example at
(http://www.doughughes.net/index.cfm?event=viewEntry&entryId=199), but
I'm still learning. Please let me know if you see my error or have a
better solution.

 

Thank for any suggestions,

Dan

 



-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Reply via email to