SHARE
TWEET

Untitled

a guest Jul 17th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $resultSetMappingBuilder = new ResultSetMappingBuilder($this->entityManager);
  2.         $resultSetMappingBuilder->addRootEntityFromClassMetadata('BeckyEntityAccount', 'a');
  3.  
  4.         $sqlQuery = 'SELECT a.* FROM `account` a
  5.             INNER JOIN `user` u
  6.             ON `u`.`account_id` = `a`.`id`
  7.             WHERE `u`.`type` = 'trial'
  8.             ORDER BY `u`.`modified_on` ASC;';
  9.         $query = $this->entityManager->createNativeQuery($sqlQuery, $resultSetMappingBuilder);
  10.      
  11. class Account extends Entity
  12. {
  13.    ....
  14.      /**
  15.      * @ORMOneToMany(targetEntity="ProjectEntityUser", cascade={"all"}, mappedBy="account")
  16.      */
  17.     protected $users;
  18.    ...
  19. }
  20.      
  21. /**
  22.  * @ORMEntity
  23.  * @ORMTable(name="user", options={"collate"="utf8_general_ci"})
  24.  * @ORMInheritanceType("SINGLE_TABLE")
  25.  * @ORMDiscriminatorColumn(name="type", type="string")
  26.  * @ORMDiscriminatorMap({
  27.  *     "trial"      = "ProjectEntityUserTrial",
  28.  *     "admin"      = "ProjectEntityUserAdmin",
  29.  *     "sales"      = "ProjectEntityUserSales"
  30.  * })
  31.  */
  32. abstract class User extends Entity
  33. {
  34. ...
  35.     /**
  36.      * @ORMManyToOne(targetEntity="ProjectEntityAccount", inversedBy="users")
  37.      * @ORMJoinColumn(name="account_id", referencedColumnName="id")
  38.      * @var Account
  39.      */
  40.     protected $account;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top