Symfony Doctrine SQLSTATE 42S02 Base Table or View not found

问题描述 投票:0回答:0

我在 Symfony Bundle 类中使用这个创建了一个带有 Doctrine 的表:

<?php

namespace Acme\Bundle\TranslationMessagesProducerBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 *
 * @ORM\Entity
 * @ORM\Table(name="acme_translation_config")
 *
 */
class AcmeTranslationMessagesProducerEntity{
    
    /**
     * id - for doctrine
     * @ORM\Column(type="integer")
     * @ORM\Id()
     * @var integer
     */
    private $id;
    
    /**
     * enabled
     * @ORM\Column(type="boolean")
     * @var mixed
     */
    private $enabled;

    public function getId(){
        return $this->id;
    }
    public function getEnabled(){
        return $this->enabled;
    }

}

运行后这张表存在

php bin/console doctrine:schema:update --force
我可以通过查询验证它是否存在
php bin/console doctrine:query:sql "Select * From acme_translation_config
或者也运行:
php bin/console doctrine:query:sql "Select * From akeneo_pim.acme_translation_config

Doctrine 也能识别它,通过运行验证:

php bin/console doctrine:mapping:info
结果:

Found 58 mapped entities: .... 
Acme\Bundle\TranslationMessagesProducerBundle\Entity\AcmeTranslationMessagesProducerEntity

但是,如果我像这样从这张表中获取一个对象:

 $em = $this->getDoctrine()->getManager();
 $config = $em->getRepository(AcmeTranslationMessagesProducerEntity::class)->find(1);

我失败了:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'akeneo_pim.acme_translation_config' doesn't exist

如何解决这个问题?

php symfony doctrine-orm doctrine akeneo
© www.soinside.com 2019 - 2024. All rights reserved.