Hi all,

 

My name is Erik-Jan, and I am just starting to learn Reactor, in combination with Model Glue. And so far, I like what I see.

But I have some questions about the way I approach some problems, I hope you can tell me if I have chosen the right approach.

 

I am building a (practice) website for a soccer club, and I want to show a page with all the upcoming matches for different clubs.

 

In my database I have a table named ‘Clubs’, with a ‘clubname’ field and a ‘clubid’ field (there are more fields, of course, but I’ll leave them out for simplicity).

Then there is a table called ‘Match’ with the field, ‘matchID, HomeTeamID, AwayTeamID, Date’.

 

In my reactor.xml file I have the following lines to configure these tables:

 

            <objects>

                        <object name="club">

                                   <hasMany name="homematch">

                                               <relate from="clubID" to="hometeamid" />

                                   </hasMany>

                                   <hasMany name="awaymatch">

                                               <relate from="ClubID" to="awayteamid" />

                                   </hasMany>

                        </object>

                        <object name="match">

                                   <hasOne name="hometeam">

                                               <relate from="hometeamid" to="company_id" />

                                   </hasOne>

                                   <hasOne name="awayteam">

                                               <relate from="awayteamid" to="company_id" />

                                   </hasOne>

                        </object>

            </objects>

 

That is question nr 1. I am not sure if this is right, in fact, I am almost sure that it’s not. The Match table holds two companyID’s. How do I declare that in the xml? Now I have a name HomeMatch and AwayMatch, but they don’t match the tablename. But if I do match the tablename, I get an error that a method cannot be declared twice. I read somewhere about aliases, I am thinking that is the way to go, but I am not sure how?

 

The second question concerns the output of the list with matches.

 

First, I do a getall for the MatchGateway. I then get a query object with all matches, but only with the clubID’s. I create two ClubRecord objects, one named HomeTeam, one named AwayTeam. In the loop over the query, I do a load for the current ClubID for both the home and the away team, and the output it as HomeTeam.getCLubName().

 

But I think there must be a quicker way to do this, by joining the two tables. I am just not sure how? Is this the right approach, or is there a better way?

 

Hope you help,

 

Kind regards,


Erik-Jan

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

Reply via email to