2
QueryBuilder的更新,我有以下原始SQL查詢:與CONCAT
UPDATE mySock s1
LEFT JOIN mySock s2
ON s1.parentId = s2.id
SET
s1.status = 1
s1.mylevel = (s2.mylevel + 1),
s1.parentString = CONCAT(s2.parentString, ':' CONCT(s1.id as char))
WHERE
s1.zz = 0;
和創造的Symfony 3.2
public function updateParentNew($idParent)
{
return $this->createQueryBuilder('s1')
->update('MyBundle:Stock', 's1')
->leftJoin(''MyBundle:Stock', 's2', 'WITH', 's2.id = s1.parentId')
->set('s1.zz', 1)
->set('s1.leveltask', 's2.leveltask + 1')
->set('s1.parentString', '?par2_string')
->where('s1.zz = 0')
->andWhere('s1.parentId = ?par1')
->setParameter('par1', $idParent)
->setParameter('par2_string', s2.parentString + ':' + (string)s1.id)
->getQuery()
->getSingleScalarResult();
}
它不工作。 Concat值(字符串和數字)的方式是什麼?
請實體'Stock'更新你的問題。 –
你會得到什麼錯誤? –