I was wondering if it was possible to configure a entity to automatically load data from another entity. Ex.
/** * accountsUsers * * @ORM\Table() * @ORM\Entity */ class accountsUsers { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ public $id; /** * @var string * * @ORM\Column(name="userid",type="integer") */ public $userid; /** * @var string * * @ORM\Column(name="roleid",type="integer") */ public $roleid; /** * @var string * admin,adviser,etc * @ORM\Column(name="roleType", type="string", length=255) */ public $roleType; /** * @var string * * @ORM\Column(name="firstname", type="string", length=255) */ public $firstname; /** * @var string * * @ORM\Column(name="lastname", type="string", length=255) */ public $lastname; /** * @var string * * @ORM\Column(name="company", type="string", length=255) */ public $company; /** * @var string * * @ORM\Column(name="url", type="string", length=255) */ public $url; /** * @var string * * @ORM\Column(name="phone", type="string", length=255) */ public $phone; /** * @var string * * @ORM\Column(name="phone2", type="string", length=255) */ public $phone2; /** * @var string * * @ORM\Column(name="address", type="string", length=255) */ public $address; /** * @var string * * @ORM\Column(name="address2", type="string", length=255) */ public $address2; /** * @var string * * @ORM\Column(name="city", type="string", length=255) */ public $city; /** * @var string * * @ORM\Column(name="state", type="string", length=255) */ public $state; /** * @var string * * @ORM\Column(name="zip", type="string", length=255) */ public $zip; /** * @var string * * @ORM\Column(name="email", type="string", length=255) */ public $email; /** * @var string * * @ORM\Column(name="password", type="string", length=255) */ public $password; }
AND
/** * accounts * * @ORM\Table() * @ORM\Entity */ class accounts { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ public $id; /** * @var string * * @ORM\Column(name="partnerid", type="string", length=100) */ public $partnerid; /** * @var \DateTime * * @ORM\Column(name="subscribedate", type="date") */ public $subscribedate; /** * @var string * * @ORM\Column(name="connectionType", type="string", length=100) */ public $connectionType; /** * @var string * * @ORM\Column(name="recordkeeperTpaid", type="string", length=100) */ public $recordkeeperTpaid; /** * @var string * * @ORM\Column(name="recordkeeperAdviceProviderCd", type="string", length=100) */ public $recordkeeperAdviceProviderCd; /** * @var string * * @ORM\Column(name="recordkeeperUrl", type="string", length=200) */ public $recordkeeperUrl; /** * @var string * * @ORM\Column(name="recordkeeperUser", type="string", length=100) */ public $recordkeeperUser; /** * @var string * * @ORM\Column(name="recordkeeperPass", type="string", length=100) */ public $recordkeeperPass; /** * @var string * * @ORM\Column(name="recordkeeperPortfoliosAvailable", type="smallint") */ public $recordkeeperPortfoliosAvailable; /** * @var string * * @ORM\Column(name="recordkeeperRiskBasedFundsAvailable", type="smallint") */ public $recordkeeperRiskBasedFundsAvailable; /** * @var string * * @ORM\Column(name="investmentsMinScore", type="integer") */ public $investmentsMinScore; /** * @var string * * @ORM\Column(name="investmentsMaxScore", type="integer") */ public $investmentsMaxScore; /** * @var string * * @ORM\Column(name="ACAon", type="smallint") */ public $ACAon; /** * @var string * * @ORM\Column(name="MSTClientID", type="string", length = 100) */ public $MSTClientID; }
Is it possible to set up accountsUsers to automatically load in all the accounts data when accountsUsers is accessed by findby, findbyone, etc. The relationship is accountsUsers.userid = accounts.id.
If not, how would I do this in a join using doctrine. I know how to do it using pure raw sql.
Ex. SELECT * FROM accounts a LEFT JOIN accountsUsers b ON a.id = b.userid