Hello!
I have Account and Group. Account belongs to Group. (ManyToOne) :
/**
* @ORM\Table(name="accounts")
* @ORM\Entity
*/
class Account {
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
*/
protected $id;
/**
* @ORM\Column(name="name", type="string")
*/
protected $name;
/**
* @ORM\ManyToOne(targetEntity="Group")
* @ORM\JoinColumn(name="group_id", referencedColumnName="id")
*/
protected $group;
}
/**
* @ORM\Table(name="groups")
* @ORM\Entity
*/
class Group {
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
*/
protected $id;
/**
* @ORM\Column(name="name", type="string")
*/
protected $name;
}
My frontend needs to select foreign keys for all ManyToOne associations.
So, I need to select group_id when I'm doing select with HYDRATE_ARRAY mode.
Next query does not return group_id value:
SELECT a FROM account a
I know that I can declare 'group_id' property for Account model but it does
not recommened by Doctrine guidelines:
class Account {
...
/**
* @ORM\Column(name="group_id", type="integer")
*/
protected $groupId;
...
}
So, does somebody know any way to select all referenced foreign keys for
model (group_id for Account in this example)?
I need something like this, but it does not work:
SELECT a,a.group_id FROM account a
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.