ドキュメントと別のスタックオーバーフローの投稿を読んで、2、3 列のデータのみを返したい場合、教義の正しい方法はパーシャルを使用することだと思いました。(これは読み取り専用クエリです)。
ただし、以下のコードは、私が特定した 3 列ではなく、100 列すべてを返します。誰かが理由を説明できますか?
ありがとう、マニシャ
public function showAction(Request $request)
{
if ($request->getMethod() == 'GET') {
$id = $request->get('locationid');
$kfType = $request->get('type');
$em = $this->getDoctrine()
->getManager();
$data = $em->createQueryBuilder()
->select ( array( 'partial d.{id, locationid, kfFyp}' ))
->from('DashDataBundle:Data', 'd')
->where('d.locationid = :locationid')
->setParameter('locationid', $id)
->setMaxResults(100)
->getQuery()
->getResult();
}