Let's say I have a Thread model, which hasMany
Post.
I want to get all Post that belongs to a certain thread.
However the query
params sent to the controller is not id
, but is the 'thread_name'
of the Thread.
What I'm doing right now is something like this:
1) Get the thread by thread_name
(for argument sake, it's unique), which will give me $thread
2) Get all post where thread_id = $thread->id
I think this is not efficient because I'm sending doing two SQL queries.
Is there anyway to select the post through thread_name
?
I'm sorry, I think this thread's title is quite confusing.