Welcome Guest, Not a member yet? Register   Sign In
Please help
#1

Hello, please i have this in my controller
$pollModel = new Poll();
$polls = $pollModel->join('options', 'options.poll_id = polls.poll_id')->findAll();
if i loop through this it works but the problem is i have an option with same poll_id that is more than one.. so it loop them differently instead of making them one..
i also tried to use groupBy()
$polls = $pollModel->join('options', 'options.poll_id = polls.poll_id')->groupBy('options.poll_id').findAll();
this is close to the answer but it only return just one option like if i have three option with same poll_id it only returns the first one..
Any help??
Reply
#2

@devprecious ,

When you do a group by it consolidates similar columns that is why you only get one record. Try orderBy()
Reply
#3

Alright but would orderBy() group the join query result as one??
Reply
#4

@devprecious ,

No, it will order all of the records by the fields you list in the order by function.
Reply
#5
Tongue 

That wasn't what I wanted.. have solved it tho, thanks
I used array_map() I don't know how to post the image here.. but it's solved now
Reply
#6

@devprecious ,

Awesome. Glad to here it. Could you please hit the Solved button. This will tell everyone that this issue has been resolved. Thx
Reply




Theme © iAndrew 2016 - Forum software by © MyBB