$comments = DB::select('comments.*', 'comment_votes.type', 'users.profile_fields')->from('comments') ->join('comment_votes','LEFT') ->on('comments.id', '=', 'comment_votes.comment_id') ->on('comment_votes.user_id', '=', $this->current_user->id) ->join('users','LEFT') ->on('comments.user_id', '=', 'users.id') ->where('article_id', $article->id);
SELECT `comments`.*, `comment_votes`.`type`, `users`.`profile_fields` FROM `comments` LEFT JOIN `comment_votes` ON (`comments`.`id` = `comment_votes`.`comment_id` AND `comment_votes`.`user_id` = `1`) LEFT JOIN `users` ON (`comments`.`user_id` = `users`.`id`) WHERE `article_id` = '3'
Harro Verton wrote on Tuesday 7th of February 2012:The Database Query Builder is originally made for MySQL, for which this is no problem. What platform and which driver are you using, and what is the error you are getting?
->on('comment_votes.user_id', '=', DB::expr($this->current_user->id))
It looks like you're new here. If you want to get involved, click one of these buttons!