用于获取特定列数据的Doctrine sql语法

How can I get only a selected items data from doctrine, here in my code I try to fetch only the apartmentId, but it returns all related data by finding it by the $userId. How can I get only and only apartmentId.

$selectData= "SELECT apartmentId FROM user_apartments WHERE userId = $userId";

$getData = $em->getConnection()->prepare($selectData); 
$getData->execute();

print_r($getData);

The sql looks incorrect - think it should be more like:-

$selectData= "SELECT `apartmentId` 
    FROM `user_apartments` 
    WHERE `userId` = '$userId';";