I create a Table with Doctrine using this in a Symfony Bundle class:
<?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;
}
}
and this table is existing after running
php bin/console doctrine:schema:update --force
i can verify it is existing by querying
php bin/console doctrine:query:sql "Select * From acme_translation_config
or also run:
php bin/console doctrine:query:sql "Select * From akeneo_pim.acme_translation_config
Doctrine also recognizes it, verified by running:
php bin/console doctrine:mapping:info
with result:
Found 58 mapped entities: ....
Acme\Bundle\TranslationMessagesProducerBundle\Entity\AcmeTranslationMessagesProducerEntity
However if i try to get a object from this table like this:
$em = $this->getDoctrine()->getManager();
$config = $em->getRepository(AcmeTranslationMessagesProducerEntity::class)->find(1);
i get the fail:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'akeneo_pim.acme_translation_config' doesn't exist
How could one resolve this?
Replace this
By this :
And check
AcmeTranslationMessagesProducerEntityRepository.phpexistsPS : You should follow the naming rules by not adding "Entity" to your class name :
AcmeTranslationMessagesProduceris better thanAcmeTranslationMessagesProducerEntity