Same Table included Twice

16 views
Skip to first unread message

George

unread,
Feb 10, 2012, 3:58:53 AM2/10/12
to ColdFusion on Wheels
I have a table of notes "NOTES" on staff members. It has two columns
for staff Id's (staffId and updatedId).

The staffId links to the staff memeber that the note is about, the
updatedId links to the staff member that wrote the note.

If I include both of these in my model , how does wheels generate my
column names since its the same table included twice?

Mohamad El-Husseini

unread,
Feb 10, 2012, 7:15:47 AM2/10/12
to cfwh...@googlegroups.com
Self-referencing tables is not possible as far as I know. You'll have to write a custom query.

George

unread,
Feb 10, 2012, 12:09:42 PM2/10/12
to ColdFusion on Wheels
I think I figured a quick work around. Just create a view of that same
table and call it something else.

Then in my model, when ever I have to reference the same table twise,
I include the view version of the second table.

On Feb 10, 6:15 am, Mohamad El-Husseini <husseini....@gmail.com>
wrote:

Mohamad El-Husseini

unread,
Feb 10, 2012, 12:11:35 PM2/10/12
to cfwh...@googlegroups.com
I've never tried using a DB view with Wheels. Itsn't it easier to just write a custom query?

George

unread,
Feb 10, 2012, 3:41:59 PM2/10/12
to ColdFusion on Wheels
A custom query is not flexible and would have to be re-written every
time it changes and it also would break conventions.

If I create a view, very simple as new view (STAFF VIEW SQL = "Select
* from Staff" save as owners.

Then my model includes hasMany("owners").

Now any my models can include both Staff and Owners just fine. Could
not be simpler.

On Feb 10, 11:11 am, Mohamad El-Husseini <husseini....@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages