Doctrine Entity在所有属性中返回NULL(ID除外)(DOCTRINE2 + ZF2)

时间:2016-05-20 00:15:05

标签: php mysql doctrine-orm zend-framework2 doctrine

我正在使用存储库进行查询。 返回仅带有正确的ID,其余属性为NULL但在数据库中所有属性都正确填充。发生了什么事?

返回:

object(UserBundle\Entity\User)#428 (15) { ["id":"UserBundle\Entity\User":private]=> int(1) ["name":"UserBundle\Entity\User":private]=> NULL ["company":"UserBundle\Entity\User":private]=> NULL ["cpf":"UserBundle\Entity\User":private]=> NULL ["cnpj":"UserBundle\Entity\User":private]=> NULL ["email":"UserBundle\Entity\User":private]=> NULL ["password":"UserBundle\Entity\User":private]=> NULL ["hash":"UserBundle\Entity\User":private]=> NULL ["plan":"UserBundle\Entity\User":private]=> NULL ["released":"UserBundle\Entity\User":private]=> NULL ["is_admin":"UserBundle\Entity\User":private]=> NULL ["created_at":"UserBundle\Entity\User":private]=> NULL ["updated_at":"UserBundle\Entity\User":private]=> NULL ["original_password":"UserBundle\Entity\User":private]=> NULL ["hydrator":"Base\Entity\AbstractEntity":private]=> NULL }

我的实体(用户):

http://pastebin.com/SBnPYY63

我的存储库(用户):

http://pastebin.com/56rwhtmZ

我的'查询':

$repository = $this->em->getRepository('UserBundle\Entity\User');
        $user = $repository->findByEmailAndPassword('email@email.com', 'password');

我的BD配置文件(doctrine_orm.local.php):

<?php

return array(
    'doctrine' => array(
        'configuration' => array(
            'orm_default' => array(
                'metadata_cache' => 'array',
                'query_cache' => 'array',
                'result_cache' => 'array',
                'hydration_cache' => 'array',
                'generate_proxies' => true,
                'proxy_dir' => 'data/DoctrineORMModule/Proxy',
                'proxy_namespace' => 'DoctrineORMModule\Proxy',
            )
        ),
        'connection' => array(
            'orm_default' => array(
                'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
                'params' => array(
                    'host' => 'localhost',
                    'port' => '3306',
                    'user' => 'root',
                    'password' => '',
                    'dbname' => 'my-project',
                    'driverOptions' => array(
                        PDO::MYSQL_ATTR_INIT_COMMAND => "SET SESSION sql_mode='ALLOW_INVALID_DATES'",
                        PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"
                    )
                )
            )
        )
    )
);

0 个答案:

没有答案