php - Laravel sql command to Laravel QueryBuilder -
i'm trying convert sql query querybuilder can't it. select a.id, a.category_name, cat.count `categories` left outer join ( select `categories`.`category_parent` , count(*) count `categories` group category_parent ) cat on a.id = cat.category_parent a.category_parent = 1 for example: db::table('users') ->join('contacts',db::raw("a.id = cat.category_parent"),function($query){ $query->select(db::raw("`categories`.`category_parent` , count( * ) count")) ->from('contacts') ->groupby('category_parent') ->where(db::raw("a.category_parent = 1")) ->get(); how fix method in laravel. thanks try getting pdo instance execute query directly: $pdo=db::connection('mysql')->getpdo(); $stmt=$pdo->prepare(" select a.id, a.category_name, cat.count `categories` left outer join ( select `categories...