我使用Doctrine的SQL查詢生成器(http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/query-builder.html)學說 - SQL查詢生成器 - 更新並加入?
並希望使用連接執行更新事件。我知道這裏不支持連接。所以我這樣做:
$query = $dbalQueryBuilder->update('s_articles_attributes', 'aa')
->set('aa.fp_pos_days', ':days')
->where('aa.articledetailsID IN (SELECT a.id FROM s_articles a WHERE a.supplierID IN (:supplierIds))')
->setParameter('days', $days_string)
->setParameter('supplierIds', $supplierIds)
->execute();
$ supplierIds是string(39) "3,4,26,28,31,36,37,38,48,49,55,56,64,82"
當我運行此查詢,什麼都不會發生。當我這樣做:
$query = $dbalQueryBuilder->update('s_articles_attributes', 'aa')
->set('aa.fp_pos_days', ':days')
->where('aa.articledetailsID IN (SELECT a.id FROM s_articles a WHERE a.supplierID IN (3,4,26,28,31,36,37,38,48,49,55,56,64,82))')
->setParameter('days', $days_string)
->execute();
它工作正常。有人知道爲什麼嗎?那我做錯了嗎?我需要使用該變量...