문제

I'm going to write MySQL query like follow query in doctrine.

UPDATE vehicle a 
INNER JOIN vehicle b ON a.id = b.id 
SET a.total_view = b.total_view+1
WHERE a.id=1;

I tried in doctrine like follow. But it doesn't work. Is there any solution for that ?

$q = Doctrine_Query::create()        
     ->update('Vehicle v')
     ->innerJoin('v.Vehicle v2')
     ->set('v.total_view = v2.total_view+1')
     ->where('v.id = ?',$id);
     return $q->execute();
도움이 되었습니까?

해결책

From what I recall in a past project, you just can't because it is not supported. You have to do it manually with native sql like this

Resources:

http://www.doctrine-project.org/jira/browse/DC-202

https://groups.google.com/forum/#!topic/doctrine-user/H0-EcZXyrek

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top