Advertisement
Guest User

Untitled

a guest
Aug 29th, 2015
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. $qb = $this->_em->createQueryBuilder()
  2. ->select('partial s.{id, activity}, partial a.{id, title}, partial p.{id, evaluationType}')
  3. ->from('InnovaPathBundleEntityStep', 's')
  4. ->leftJoin('s.activity', 'a') //join on Activity entity
  5. ->leftJoin('a.parameters', 'p') // join on ActivityParameters entity
  6. ->andWhere('s.path = 2')
  7. ;
  8.  
  9. /**
  10. * @ORMTable(
  11. * name="claro_activity_evaluation",
  12. * uniqueConstraints={
  13. * @ORMUniqueConstraint(
  14. * name="user_activity_unique_evaluation",
  15. * columns={"user_id", "activity_parameters_id"}
  16. * )
  17. * }
  18. * )
  19. */
  20. class Evaluation
  21. {
  22. /**
  23. * @ORMManyToOne(targetEntity="ClarolineCoreBundleEntityUser")
  24. * @ORMJoinColumn(onDelete="CASCADE", nullable=false)
  25. */
  26. protected $user;
  27.  
  28. /**
  29. * @ORMManyToOne(targetEntity="ClarolineCoreBundleEntityActivityActivityParameters")
  30. * @ORMJoinColumn(name="activity_parameters_id", onDelete="CASCADE", nullable=false)
  31. */
  32. protected $activityParameters;
  33.  
  34. /**
  35. * @ORMColumn(name="attempts_count", type="integer", nullable=true)
  36. */
  37. protected $attemptsCount;
  38.  
  39. }
  40.  
  41. /**
  42. * @ORMTable(name="claro_user")
  43. * @ORMEntity(repositoryClass="ClarolineCoreBundleRepositoryUserRepository")
  44. */
  45. class User
  46. {
  47. /**
  48. * @var integer
  49. *
  50. * @ORMId
  51. * @ORMColumn(type="integer")
  52. * @ORMGeneratedValue(strategy="AUTO")
  53. */
  54. protected $id;
  55.  
  56. /**
  57. * @var string
  58. *
  59. * @ORMColumn(name="first_name", length=50)
  60. * @AssertNotBlank()
  61. */
  62. protected $firstName;
  63.  
  64. }
  65.  
  66. /**
  67. * @ORMEntity
  68. * @ORMTable(name="claro_activity_parameters")
  69. */
  70. class ActivityParameters
  71. {
  72. /**
  73. * @var integer
  74. *
  75. * @ORMId
  76. * @ORMColumn(type="integer")
  77. * @ORMGeneratedValue(strategy="AUTO")
  78. */
  79. protected $id;
  80.  
  81. /**
  82. * @var ClarolineCoreBundleEntityResourceActivity
  83. *
  84. * @ORMOneToOne(
  85. * targetEntity="ClarolineCoreBundleEntityResourceActivity",
  86. * mappedBy="parameters"
  87. * )
  88. * @ORMJoinColumn(name="activity_id", onDelete="CASCADE", nullable=true)
  89. */
  90. protected $activity;
  91.  
  92. /**
  93. * @var string
  94. *
  95. * @ORMColumn(name="evaluation_type", nullable=true)
  96. */
  97. protected $evaluationType;
  98.  
  99. /**
  100. * @return string
  101. */
  102. public function getEvaluationType()
  103. {
  104. return $this->evaluationType;
  105. }
  106. }
  107.  
  108. /**
  109. * @ORMTable(name="claro_activity")
  110. */
  111. class Activity
  112. {
  113. /**
  114. * @var string
  115. * @ORMColumn(length=255, nullable=true)
  116. */
  117. protected $title;
  118.  
  119. /**
  120. * @ORMOneToOne(
  121. * targetEntity="ClarolineCoreBundleEntityActivityActivityParameters",
  122. * inversedBy="activity",
  123. * cascade={"persist"}
  124. * )
  125. * @ORMJoinColumn(name="parameters_id", onDelete="cascade", nullable=true)
  126. */
  127. protected $parameters;
  128.  
  129. /**
  130. * @return string
  131. */
  132. public function getTitle()
  133. {
  134. return $this->title;
  135. }
  136. }
  137.  
  138. $qb = $this->_em->createQueryBuilder()
  139. ->select('partial s.{id, activity}, partial a.{id, title}, partial p.{id, evaluationType}')
  140. ->from('InnovaPathBundleEntityStep', 's')
  141. ->leftJoin('s.activity', 'a') //join on Activity entity
  142. ->leftJoin('a.parameters', 'p') // join on ActivityParameters entity
  143. ->andWhere('s.path = 2')
  144. ->leftJoin('?i dont know what?', 'e') // join on Evaluation entity
  145. ->andWhere('e.user = 3') //data for a specific user
  146. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement