如何在DELETE QUERY中编写LEFT JOIN?

Leo*_*rdo 4 php doctrine

你能给我一个使用Doctrine使用左连接的删除查询的例子吗?

小智 6

这是不可能的.见:http://trac.doctrine-project.org/ticket/2142

您必须在where子句中使用子查询:http://www.doctrine-project.org/documentation/manual/1_2/en/dql-doctrine-query-language : subqueries

尝试类似的东西:

$q = Doctrine_Query::create()
    ->delete('TableB b')
    ->where('b.id NOT IN (SELECT b.id FROM TableB b \
          INNER JOIN b.TableA a WHERE b.date > NOW() AND a.channel_id = 10)')
    ->execute();
Run Code Online (Sandbox Code Playgroud)