Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $sql = "SELECT DISTINCT {TC.id}, {T.id}, {T.tag}, IF (ACT.tag_id IS NULL, 0, 1) AS status
- FROM exercise_tag ET2, tag T LEFT JOIN
- (
- SELECT ET.tag_id
- FROM exercise_tag ET,
- (
- SELECT E.exercise_id
- FROM exercise_tag E
- WHERE E.tag_id IN ('29','1')
- GROUP BY E.exercise_id
- HAVING count(E.exercise_id) = 2
- )
- EX WHERE ET.exercise_id=EX.exercise_id
- GROUP BY ET.tag_id
- )
- ACT ON (T.id=ACT.tag_id)
- LEFT JOIN tag_category TC ON (T.category_id=TC.id)
- WHERE
- ET2.tag_id=T.id
- ORDER BY TC.id" " ;
- $q = new Doctrine_RawSql();
- $q->parseQuery($sql);
- $q->addComponent('ET', 'ExerciseTag');
- $q->addComponent('T', 'Tag');
- $q->addComponent('ETSEL', 'ExerciseTag');
- $q->addComponent('TC', 'TagCategory');
- $q->addComponent('ET2', 'ExerciseTag');
- $q->execute(array(), Doctrine::HYDRATE_ARRAY);
Add Comment
Please, Sign In to add comment