Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $qb = $this->_em->createQueryBuilder()
- ->select('partial s.{id, activity}, partial a.{id, title}, partial p.{id, evaluationType}')
- ->from('InnovaPathBundleEntityStep', 's')
- ->leftJoin('s.activity', 'a') //join on Activity entity
- ->leftJoin('a.parameters', 'p') // join on ActivityParameters entity
- ->andWhere('s.path = 2')
- ;
- /**
- * @ORMTable(
- * name="claro_activity_evaluation",
- * uniqueConstraints={
- * @ORMUniqueConstraint(
- * name="user_activity_unique_evaluation",
- * columns={"user_id", "activity_parameters_id"}
- * )
- * }
- * )
- */
- class Evaluation
- {
- /**
- * @ORMManyToOne(targetEntity="ClarolineCoreBundleEntityUser")
- * @ORMJoinColumn(onDelete="CASCADE", nullable=false)
- */
- protected $user;
- /**
- * @ORMManyToOne(targetEntity="ClarolineCoreBundleEntityActivityActivityParameters")
- * @ORMJoinColumn(name="activity_parameters_id", onDelete="CASCADE", nullable=false)
- */
- protected $activityParameters;
- /**
- * @ORMColumn(name="attempts_count", type="integer", nullable=true)
- */
- protected $attemptsCount;
- }
- /**
- * @ORMTable(name="claro_user")
- * @ORMEntity(repositoryClass="ClarolineCoreBundleRepositoryUserRepository")
- */
- class User
- {
- /**
- * @var integer
- *
- * @ORMId
- * @ORMColumn(type="integer")
- * @ORMGeneratedValue(strategy="AUTO")
- */
- protected $id;
- /**
- * @var string
- *
- * @ORMColumn(name="first_name", length=50)
- * @AssertNotBlank()
- */
- protected $firstName;
- }
- /**
- * @ORMEntity
- * @ORMTable(name="claro_activity_parameters")
- */
- class ActivityParameters
- {
- /**
- * @var integer
- *
- * @ORMId
- * @ORMColumn(type="integer")
- * @ORMGeneratedValue(strategy="AUTO")
- */
- protected $id;
- /**
- * @var ClarolineCoreBundleEntityResourceActivity
- *
- * @ORMOneToOne(
- * targetEntity="ClarolineCoreBundleEntityResourceActivity",
- * mappedBy="parameters"
- * )
- * @ORMJoinColumn(name="activity_id", onDelete="CASCADE", nullable=true)
- */
- protected $activity;
- /**
- * @var string
- *
- * @ORMColumn(name="evaluation_type", nullable=true)
- */
- protected $evaluationType;
- /**
- * @return string
- */
- public function getEvaluationType()
- {
- return $this->evaluationType;
- }
- }
- /**
- * @ORMTable(name="claro_activity")
- */
- class Activity
- {
- /**
- * @var string
- * @ORMColumn(length=255, nullable=true)
- */
- protected $title;
- /**
- * @ORMOneToOne(
- * targetEntity="ClarolineCoreBundleEntityActivityActivityParameters",
- * inversedBy="activity",
- * cascade={"persist"}
- * )
- * @ORMJoinColumn(name="parameters_id", onDelete="cascade", nullable=true)
- */
- protected $parameters;
- /**
- * @return string
- */
- public function getTitle()
- {
- return $this->title;
- }
- }
- $qb = $this->_em->createQueryBuilder()
- ->select('partial s.{id, activity}, partial a.{id, title}, partial p.{id, evaluationType}')
- ->from('InnovaPathBundleEntityStep', 's')
- ->leftJoin('s.activity', 'a') //join on Activity entity
- ->leftJoin('a.parameters', 'p') // join on ActivityParameters entity
- ->andWhere('s.path = 2')
- ->leftJoin('?i dont know what?', 'e') // join on Evaluation entity
- ->andWhere('e.user = 3') //data for a specific user
- ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement