mysql到symfony 1.4.9中的Criteria()

时间:2011-04-09 10:21:05

标签: symfony1 symfony-1.4 propel

我在mySQL中有以下复杂查询

SELECT courseId,courseName
FROM course WHERE courseId NOT IN (SELECT courseId FROM coursestaken NATURAL JOIN student WHERE grade >= 60 AND studentId =2) 
AND
courseId NOT IN (SELECT courseId FROM stable WHERE studentId = 2 )
AND
courseId NOT IN (SELECT DISTINCT courseId FROM prerequisites 
WHERE
prereqId NOT IN (SELECT courseId FROM coursestaken NATURAL JOIN student WHERE grade >= 60 AND studentId =2  )) ; 

有人可以帮我将其转换为Propel中的Criteria()查询吗?

1 个答案:

答案 0 :(得分:4)

尝试在下面的推进中使用prepare函数

    $con=Propel::getConnection();
            $obj = $con->prepare("SELECT courseId,courseName
FROM course WHERE courseId NOT IN (SELECT courseId FROM coursestaken NATURAL JOIN student WHERE grade >= 60 AND studentId =2) 
AND
courseId NOT IN (SELECT courseId FROM stable WHERE studentId = 2 )
AND
courseId NOT IN (SELECT DISTINCT courseId FROM prerequisites 
WHERE
prereqId NOT IN (SELECT courseId FROM coursestaken NATURAL JOIN student WHERE grade >= 60 AND studentId =2  )) ");
            $obj->execute();
            $resultset = $obj->fetchAll();