I just realize that in symfony if you didn't not mention specific field the doctrine will return you a lot of junk data such as debug time and etc. How can we query all database field with only the field results? Example: SELECT * FROM user WHERE username = 'abc', then it will only return all fields in user table not including those junk data.
$q = $this
->createQueryBuilder('u')
->where('u.username = :username')
->setParameter('username', $username)
->getQuery();
try {
// The Query::getSingleResult() method throws an exception
// if there is no record matching the criteria.
$user = $q->getSingleResult();
var_dump($user);
} catch (NoResultException $e) {
$user = false;
}
The results of the above code:
I don't need all those data, I only need the fields in the data. Your help is very much appreciated. Thank you.