I have the following two queries:
$query = $this->doctrine->em->createQuery("select u from ORM\Dynasties2\Characters u WHERE u.whichFamily = $whichfamily AND (u.deathDate = 0 OR u.deathDate IS NULL) ");
and
$query = $this -> doctrine -> em -> createQuery ("SELECT a, b.msgText, b.fromUser, b.timeStamp, b.importance, b.msgType FROM ORM\Dynasties2\Maillinks a JOIN a.msgId b");
The first query returns an object.
array(9) {
[0]=> object(stdClass)#108 (18) {
["__CLASS__"]=> string(25) "ORM\Dynasties2\Characters"
["id"]=> int(67)
(etc)
The second query returns an array.
array(4) {
[0]=> array(6) {
[0]=> string(24) "ORM\Dynasties2\Maillinks"
["msgText"]=> string(24) "asdfasdfasdfasdfasdfasdf"
(etc)
Why does the second one return an array?
Is there a simple way to convert it into an object?
(using doctrine2 and codeigniter2)
Edit:
If I change the second query like so:
$query = $this -> doctrine -> em -> createQuery ("SELECT a FROM ORM\Dynasties2\Maillinks a JOIN a.msgId b");
then the output is an object. So I’ve partly answered my question – however, the above code does not return the data that I need.
Try this (if the relationship is defined properly, it should return and object):