Problems persisting data in Doctrine

Asked

Viewed 83 times

0

I am doing this:

  function Autenticar($objecto) {

        //require $this->db;
        require ROOT . "config/bootstrap.php";

        return $entityManager->getRepository('models\Usuarios')->findOneBy(array('login' => $objecto->login, 'senha' => $objecto->senha));
    }

He returns it to me:

Class "Usuarios models" is not a Valid Entity or Mapped super class.

Does anyone have any idea what’s going on?

I’ve fought here and got nothing.

  • The repository returns one, or a collection of entities. You are defining that this entity is models\Usuarios, that’s right?

  • this is the way my class is mapped. the path is user models (models and the name of my namespace)

  • You have to pass the full class path. If you have a class Usuario inside the namespace Models\Usuarios, then you have to use Models\Usuarios\Usuario. And stick to capital letters too.

  • OK, thank you was even this! valeuu

1 answer

1

I changed the setting for Entity manager this way

setting the settings previously defined

$config = Setup::createAnnotationMetadataConfiguration($entidades, $isDevMode, NULL, NULL, FALSE); //adicionei Null no 3 e 4 parametro, e no 5 parametro coloquei true pra ele aceitar  uso de NAMESPACE..

creating Entity Manager based on dev and database settings

$entityManager = EntityManager::create($dbParams, $config);

OK Thanks for the help

Browser other questions tagged

You are not signed in. Login or sign up in order to post.