我有这个查询:
$query = $this->_em->createQuery(
"UPDATE PublicBundle:Table1 t1
JOIN PublicBundle:Table2 t2 WITH t1.ad_id = t2.id
SET t1.status = :status
WHERE t1.status IN (':statuses')
AND t2.updated_at < ':dateLimit'"
)->setParameter('status', 1)
->setParameter('statuses', implode(",", $statuses))
->setParameter('dateLimit', new DateTime(sprintf('-%d day', $date))
echo $query->getSQL();
$query->execute();
但是我收到错误:
Error: Expected DoctrineORMQueryLexer::T_EQUALS, got 't2');
你能帮我吗?提前感谢
$sql ="UPDATE Table1 t1
JOIN Table2 t2 ON t1.ad_id = t2.id
SET t1.status = :status
WHERE t1.status IN (':statuses')
AND t2.updated_at < ':dateLimit'";
$params=array(
'status'=>1,
'statuses'=> implode(",", $statuses)
'dateLimit'=>new DateTime(sprintf('-%d day', $date)
);
return $this->getEntityManager()->getConnection()->executeQuery($sql, $params);
尝试在自定义存储库中使用它。首先在你的phpmyadmin中进行硬编码,然后在你的脚本上尝试这个sql