I'm stumped. I need to access the next nth row
in a query loop to show version differences between posts.
I'm using <cfquery>
to output the revisions by group, and this is my expected output:
Rev4
diff(rev4.title, original.title)
diff(rev4.brief, rev2.brief)
Rev3
diff(rev3.body, rev2.body)
Rev2
diff(rev2.brief, original.brief)
diff(rev2.body, original.body)
Original
query.title
query.brief
query.body
I initially thought to use Java methods to get the next query row. This does not work:
- Rev4 needs to show the difference between its own brief row, and the last revision made to the brief row; which, in this case, occurred in Rev2; so it needs to jump one row.
- In order to show the diff for its title row, Rev4 needs to jump to the original post since the first change to the title row occurred in Rev4 itself.
Some things to consider:
- The revisions schema is one row for each edited post column; so if you load a post and edit its title and body, two records will get created in the revisions schema; one for the title and one for the body, under the same revisionGUID.
- The query is grouped by revisionGUID.
- It's ordered by revision date, newest to oldest; then by revision type (title, brief, body).
I tagged this with Java because ColdFusion allows us to use Java methods on queries objects, but it's not documented so merely knowing of its existence does not help me.
Anyone can show me a [better] way to do this?
The code structure I thought of:
<cfoutput query="revisions" group="revisionGUID">
#revision.revisionGUID#
<cfoutput>
// conditional logic to get diff();
<cfoutput>
</cfoutput>