草庐IT

Doctrine_Record

全部标签

php - 使用 Doctrine 实体和 JMSserializer 避免递归

我正在使用Symfony2、Doctrine、FOSRestBundle和JMSSerializer构建RESTAPI。我遇到的问题是在序列化我的实体时,序列化程序会引入任何相关实体。例如,对于作为故事的一部分的任务,故事是板的一部分,因此在序列化任务时,我得到的输出包括故事,故事包括板,然后包括板上的所有其他故事。有没有一种简单的方法来限制它,而只包含foreignIds呢? 最佳答案 使用JMS排除策略。在类别实体上使用注释的示例,您不想在其中包含要包含的子项和产品相关实体:use...JMS\SerializerBundle\

php - 使用 Doctrine 实体和 JMSserializer 避免递归

我正在使用Symfony2、Doctrine、FOSRestBundle和JMSSerializer构建RESTAPI。我遇到的问题是在序列化我的实体时,序列化程序会引入任何相关实体。例如,对于作为故事的一部分的任务,故事是板的一部分,因此在序列化任务时,我得到的输出包括故事,故事包括板,然后包括板上的所有其他故事。有没有一种简单的方法来限制它,而只包含foreignIds呢? 最佳答案 使用JMS排除策略。在类别实体上使用注释的示例,您不想在其中包含要包含的子项和产品相关实体:use...JMS\SerializerBundle\

php - 如何用 Doctrine 查询 NOT NULL?

我有表测试:Test:id|name1|aaa2|3|ccc4|aaa5|6|ddd我想要名称不为空的结果:aaacccaaaddd我怎样才能得到:Doctrine_Core::getTable('Test')->findBy('name',NOTNULL??)并在模型中:$this->createQuery('u')->where('name=?',NOTNULL???)execute(); 最佳答案 试试这个:$this->createQuery('u')->where('nameISNOTNULL')->execute();这

php - 如何用 Doctrine 查询 NOT NULL?

我有表测试:Test:id|name1|aaa2|3|ccc4|aaa5|6|ddd我想要名称不为空的结果:aaacccaaaddd我怎样才能得到:Doctrine_Core::getTable('Test')->findBy('name',NOTNULL??)并在模型中:$this->createQuery('u')->where('name=?',NOTNULL???)execute(); 最佳答案 试试这个:$this->createQuery('u')->where('nameISNOTNULL')->execute();这

php - Doctrine ReflectionException 属性不存在

我正在尝试在现有数据库之上添加Doctrine。我让Doctrine生成带注释的实体并从那里进行调整。当我尝试加载下面的实体时,出现错误PHPFatalerror:Uncaughtexception'ReflectionException'withmessage'PropertyUsers\\User::$resellerIDdoesnotexist'classUser{/*...*//***@var\Doctrine\Common\Collections\Collection**@ORM\ManyToOne(targetEntity="\Resellers\Reseller")*@O

php - Doctrine ReflectionException 属性不存在

我正在尝试在现有数据库之上添加Doctrine。我让Doctrine生成带注释的实体并从那里进行调整。当我尝试加载下面的实体时,出现错误PHPFatalerror:Uncaughtexception'ReflectionException'withmessage'PropertyUsers\\User::$resellerIDdoesnotexist'classUser{/*...*//***@var\Doctrine\Common\Collections\Collection**@ORM\ManyToOne(targetEntity="\Resellers\Reseller")*@O

php - Symfony Doctrine auto_mapping 无法识别

我已经添加了SonataUserBundle,但出现错误配置.ymldoctrine:orm:auto_generate_proxy_classes:"%kernel.debug%"naming_strategy:doctrine.orm.naming_strategy.underscoreauto_mapping:trueentity_managers:default:mappings:ApplicationSonataUserBundle:~SonataUserBundle:~错误Unrecognizedoptions"naming_strategy,auto_mapping,dq

php - Symfony Doctrine auto_mapping 无法识别

我已经添加了SonataUserBundle,但出现错误配置.ymldoctrine:orm:auto_generate_proxy_classes:"%kernel.debug%"naming_strategy:doctrine.orm.naming_strategy.underscoreauto_mapping:trueentity_managers:default:mappings:ApplicationSonataUserBundle:~SonataUserBundle:~错误Unrecognizedoptions"naming_strategy,auto_mapping,dq

php - Doctrine 集合的 Docblocks

在Doctrine项目的docblock注释中,是否有一种标准方法来记录Collection中预期的实体类?像这样的东西:/***@varCollection*/protected$users;看起来PHPDoc现在是docblock注释的实际标准,但我找不到关于这个用例的任何提及。 最佳答案 这是一个解决方案,使您能够在Collection方法和您的objects方法上都有自动完成功能:/***@paramCollection|User[]$users*/publicfunctionfoo($users){$users->//au

php - Doctrine 集合的 Docblocks

在Doctrine项目的docblock注释中,是否有一种标准方法来记录Collection中预期的实体类?像这样的东西:/***@varCollection*/protected$users;看起来PHPDoc现在是docblock注释的实际标准,但我找不到关于这个用例的任何提及。 最佳答案 这是一个解决方案,使您能够在Collection方法和您的objects方法上都有自动完成功能:/***@paramCollection|User[]$users*/publicfunctionfoo($users){$users->//au