gpt4 book ai didi

php - 代理对象而不是 Doctrine 中的实体

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

我在使用 Doctrine 和 Symfony 时遇到了一个问题。我得到的不是 AppBundle\Entity\Item `Proxies__CG__\AppBundle\Entity\Item。所有数据 = null。

$test = $em->getRepository(Entity\Item::class)->find(159);
var_dump($test); exit;

我应该改变什么?

object(Proxies\__CG__\AppBundle\Entity\Item)[5348]
public '__initializer__' =>
object(Closure)[5237]
public '__cloner__' =>
object(Closure)[5802]
public '__isInitialized__' => boolean false
private 'id' (AppBundle\Entity\Item) => int 159
private 'name' (AppBundle\Entity\Item) => null
private 'slug' (AppBundle\Entity\Item) => null
private 'description' (AppBundle\Entity\Item) => null
private 'price' (AppBundle\Entity\Item) => null
private 'isFixedPrice' (AppBundle\Entity\Item) => null
private 'isExchangable' (AppBundle\Entity\Item) => null
private 'isDeliverable' (AppBundle\Entity\Item) => null
private 'totalViewsCount' (AppBundle\Entity\Item) => null
private 'condition' (AppBundle\Entity\Item) => null
private 'soldAt' (AppBundle\Entity\Item) => null
private 'category' (AppBundle\Entity\Item) => null
private 'user' (AppBundle\Entity\Item) => null
private 'attributes' (AppBundle\Entity\Item) => null
private 'pics' (AppBundle\Entity\Item) => null
protected 'createdAt' => null
protected 'updatedAt' => null
protected 'deletedAt' => null

我必须获取 $test->getItem()->getSlug()。在数据库中存在具有此 ID 的项目。

最佳答案

我找到了解决方案。以前的开发人员使用 @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=true)所以有些行在数据库中有 deleted_at 值。这是他们不返回任何数据的方式。

关于php - 代理对象而不是 Doctrine 中的实体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46146355/

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