mysql to Criteria () в symfony 1.4.9 - PullRequest
       10

mysql to Criteria () в symfony 1.4.9

2 голосов
/ 09 апреля 2011

У меня следующий сложный запрос в 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  )) ; 

Может ли кто-нибудь помочь мне преобразовать это в запрос Criteria () в Propel?

1 Ответ

4 голосов
/ 09 апреля 2011

Попробуйте использовать функцию подготовки в Propel, как показано ниже

    $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();
...