我想以对象格式获取doctrin2查询结果,但它以数组格式提供给我。 我试过但我不能成功。
这是演示查询,但是如果我想在另一个查询中应用类似类型的连接,那么也需要对象格式的结果,但是在所有这些中都需要。
你能解决吗?
return $this->createQueryBuilder("u")
->select("u.id as userid, up.id as profileid, u.username, u.email, u.isactive, up.firstname, up.lastname, up.profileimage, up.address, up.zipcode, up.biography")
->innerjoin("u.userprofile", "up")
->where("u.id = :userid")
->setParameter(":userid", $userid)
->getQuery()
->getResult();
ResultSet:
Array
(
[userid] => 4
[profileid] => 3
[username] => Test user
[email] => testuser@yahoo.com
[isactive] => 1
[firstname] => MyFname
[lastname] => MyLname
[profileimage] => 5111ea998c9476c2231180050d5ad64dc3298fe0.jpeg
[address] => My Address
[zipcode] => 36102555
[biography] => This is my first symfon2.3 project.
)