草庐IT

php - 学说持久化实体在 entityManager->persist 和 unitOfWork->persist 之间改变

在我的symfony2/doctrine2应用程序中,我有一个奇怪的情况,当持久化修改后的实体时,更改没有刷新到数据库,我不明白为什么。下面是我的代码:$date=$subscription->getPaymentValidUntil()->format('d/m/Y');$period=$payment->getDetail('period');$validDate=$subscription->getPaymentValidUntil()->add(new\DateInterval($period==Subscription::MONTH?'P1M':'P1Y'));$subscr

php - 如何在不同的限界上下文中将学说实体拆分为更多领域实体?

我正在DDD(Domain-drivendesign)领域尝试我的第一步。我喜欢这个明智的规则,你应该将你的实体分成许多更小的、特定于上下文的实体(例如User实体几乎在每个非ddd或设计不佳的应用程序中都会过度增长)。但是,关于如何使用Doctrine在php中(有效地)执行此操作的常见选项是什么?假设我有两个限界上下文:Store和Invoicing他们每个人都有两个领域实体:对于StoreBC,它是FirstTimeCustomer和RecurrentCustomer对于InvoicingBC,它是VatCustomer和NonVatCustomer现在,在我的基础架构层中,我希

php - 学说迁移 2 + zend 框架 2 = 可能吗?

我用过这个指南http://www.jasongrimes.org/2012/01/using-doctrine-2-in-zend-framework-2/现在我有了一个可以工作的Doctrine2+ZF2软件。我使用一个版本控制系统,然后我想使用DoctrineMIGRATIONS工具来拥有一个数据库迁移系统。如果我使用shell./doctrine-moduleorm:schema-tool:update它可以正常工作,但是如果我使用迁移工具,例如./doctrine-modulemigrations:status系统给我一个错误:[Doctrine\DBAL\Migration

php - 对学说的@OneToMany ArrayCollection 进行排序

我的问题接近thisone,但与我的不完全吻合。我在实体中有此列:/***@varArrayCollection[SubjectTag]**@ORM\OneToMany(targetEntity="SubjectTag",mappedBy="subject")*@Assert\Count(max=10,maxMessage="Youcan'tcreatemorethan10tags.")*@Assert\Valid()*/protected$subjectTags;我想根据SubjectTag.position中定义的位置对我的标签进行动态排序。 最佳答案

php - Symfony2 - 学说 :schema:update fails with entity outside of a bundle ( decoupled )

我正在阅读这篇文章:http://danielribeiro.org/yes-you-can-have-low-coupling-in-a-symfony-standard-edition-application/作者提到项目可以有这样的结构:src/└──Vendor/└──Product/└──Bundle└──BlogBundle/└──ForumBundle/└──SiteBundle/└──Controller/└──IndexController.php└──Resources/└──views/└──index.html.twig└──ProductSiteBundle.

php - 学说 2 实体 : are they supposed to contain logic?

学说网站已关闭,所以我在这里寻找信息:应该包含Doctrine2实体的内容:只有属性和getter和setter属性、getter/setter和领域逻辑谢谢 最佳答案 一些域逻辑很好,如果它适用于实体本身。例如,以下内容很好:classmyEntity{//.../***@OneToMany(targetEntity="LineItem")*/protected$items;publicfunctionequals($otherEntity){//compare$this->lineItemsand$otherEntity->li

php - 如何在 Zend Framework 2 中配置学说扩展?

我已将此行添加到我的composer.json中:"gedmo/doctrine-extensions":"dev-master"这是在我模块的module.config.php中:'doctrine'=>array('driver'=>array(__NAMESPACE__.'_driver'=>array('class'=>'Doctrine\ORM\Mapping\Driver\AnnotationDriver','cache'=>'array','paths'=>array(__DIR__.'/../src/'.__NAMESPACE__.'/Entity'),),'orm_d

php - 学说 : how to add custom functions that take optional parameter?

按照官方解释,我想创建我的自定义MySQL函数ROUND(),它可以接受(非强制性)另一个第二个参数。到目前为止,我已经这样做了:walkSimpleArithmeticExpression($this->simpleArithmeticExpression).')';}publicfunctionparse(\Doctrine\ORM\Query\Parser$parser){$lexer=$parser->getLexer();$parser->match(Lexer::T_IDENTIFIER);$parser->match(Lexer::T_OPEN_PARENTHESIS);

php - 未找到学说迁移包 - symblog

作为symfony博客教程的一部分,我已经成功地通过命令行安装了doctrinemigrations。symblogtutorialpart4但是我现在得到类找不到错误?Fatalerror:Class'Doctrine\Bundle\DoctrineMigrationsBundle\DoctrineMigrationsBundle'notfoundin/media/sf_projects/symBlog/app/AppKernel.phponline24但是我不确定为什么我得到它路径对我来说看起来是正确的,请参阅下面的屏幕截图? 最佳答案

php - 学说 : Set primary Key

我有一个包含一些字段的表,第一个是我的主键,称为token。我需要token不是自动的,所以,我想设置这个值。例如,$em=$this->getDoctrine()->getManager();$object->setToken("first");$object->setValue("123");$em->persist($object);$em->flush();但是,在我的数据库中,token总是null,为什么?当我刷新时,token值消失。在我的实体中,声明了token:/***@varstring**@ORM\Column(name="token",type="string"