gpt4 book ai didi

php - 预期的字符串结尾,在 DQL Symfony 中使用 LIMIT 时得到 'LIMIT'

转载 作者:行者123 更新时间:2023-12-05 05:17:40 26 4
gpt4 key购买 nike

我需要从我的表中获取最后一个 ID,以便我可以在另一个函数中使用它我在我的存储库中创建了这个函数,但我没有工作,它显示了一个错误:

[Syntax Error] line 0, col 60: Error: Expected end of string, got 'LIMIT'

我正在使用的功能:

         public function LastIdCart()
{
$query = $this->getEntityManager()
->createQuery("select i.id from BoutiqueBundle:Panier i ORDER BY
i.id DESC LIMIT 1");
return $query->getResult();
}

最佳答案

class YourController extends Controller {

*********************************************************
public function yourAction( *** ) {
$youLastRecord = $this->getDoctrine()->getRepository(YourEntity::class)->findOneBy(
array(),
array('id' => 'DESC')
);
}
}

关于php - 预期的字符串结尾,在 DQL Symfony 中使用 LIMIT 时得到 'LIMIT',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48974184/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com