I've been struggle for hours with the follow join issue in Zend Framework.
My table(s)
Table (websites)
- id
- user_id
- website
- url
- ...
Table (users)
- id
- username
- salt
- password
- ...
Table (reviews)
- id
- website_id (id of website)
- user_id (id from the user/owner of the website)
- reviewer_id (id from the user who has reviewed the website)
- review
- ...
What do I want to get..
To make a array with join of the review and user data is no problem, but I want also
add the website compare to the review.
I made the follow join but I won't work like I want, I have just 3 test reviews in my database and I'm getting over 12 results in my array.
My query:
$select = $this->_db->select() ->from('reviews') ->joinLeft('users', 'reviews.reviewer_id = users.id') ->joinLeft('websites', 'reviews.user_id = reviews.user_id') ->where("reviews.user_id = $user_id");
$result = $this->getAdapter()->fetchAll($select);
With kind regards,
Nicky