草庐IT

Doctrine_RawSql

全部标签

php - Symfony Doctrine 优化

我在USER和CATEGORY表之间有MN关系。当用户有超过100个兴趣时出现问题。当我像这样执行非常简单的查询时:return$this->createQueryBuilder('usercategory')->innerJoin('usercategory.user','u')->innerJoin('usercategory.category','c')->where('u.id=:user_id')->setParameter('user_id',$user_id)->getQuery()->getResult();Symfony分析器报告超过100个查询的执行时间超过150毫

php - Symfony2 - 在处理实体时覆盖默认的 Doctrine 查询

对于我的项目,我有一个包含许多项目的工作区(一种用户),我想知道是否有一种方法可以在我调用$workspace->getProjects()只获取事件项目(不是存档的项目)。这样我就不必过滤我的集合,而且它会减少从数据库返回的数据的大小。/***Acme\DemoBundle\Entity\Workspace**@ORM\Table()*@ORM\Entity*/classWorkspace{/***@varinteger$id**@ORM\Column(name="id",type="integer")*@ORM\Id*@ORM\GeneratedValue(strategy="AU

php - 内存管理 Symfony 表单和 Doctrine

当使用Symfony构建表单时,表单的构建速度非常慢并且内存峰值。该表单是使用一些子表单构建的,并使用了一些一对多关系。当表单的数据变大(多方实体更多)时,表单变慢并且内存使用量越来越大,这看起来不错,但时间和内存使用量似乎不是。例如,当多边有大约71个实体时,内存使用量约为116MB,加载需要14秒。我已经推断出完成的查询数量(从75到4),尽管内存峰值仍然在创建表单的那一刻发生$form=$this->createForm(newTapsAndAppliancesType(),$taps);有什么提示和技巧可以加快速度吗? 最佳答案

php - 获取 "Integrity constraint violation: 1048 Column ' payment_id' cannot be null"using Doctrine & Symfony

我已经被困了几天来处理这个问题。我一直在查看其他StackOverflow问题和不同的论坛,但我无法让它工作,所以这就是这个问题的原因。我正在开发一个包含付款的系统,所以我创建了一个“付款”类,如下所示:/***Payment**@ORM\Table()*@ORM\Entity(repositoryClass="PaymentRepository")*/classPayment{/***@varinteger**@ORM\Column(name="id",type="integer")*@ORM\Id*@ORM\GeneratedValue(strategy="AUTO")*@JMS\

php - Symfony 2 Doctrine MS SQL 错误

我已经开始从事Symfony2.3项目,我需要将用经典Asp编写的金融网站转换为Php。客户端有要与Symfony2.3和doctrine一起使用的Ms-Sql数据库,我已经创建了数据库并从模式文件中加载了空表。现在,每当我尝试从数据库(Ms-Sql)生成实体时,我都会收到以下错误:Doctrine\DBAL\DBALExceptionUnknowndatabasetypetimestamprequested,Doctrine\DBAL\Platforms\SQLServer2008Platformmaynotsupportit有谁知道如何解决这个问题或者我应该怎么做才能避免这种情况?

php - Symfony 2/Doctrine : How to lower the num of queries without losing the benefit of ORM?

我正在使用Symfony2.7和Doctrine。我的Controller操作通常如下所示:#my/namespace/Controller/ItemsController.php->listAction()$items=$this->get('repository.items')->findAll();return$this->render('itemsList.html.twig',array('items'=>$items));在我的模板中,我喜欢迭代关联的实体:#my/namespace/Resources/views/itemsList.html.twig{%foritemi

php - 如何在 Symfony 2 和 Doctrine 中过滤实体对象内的数据

我有两个实体:Product和Feature。Product还有许多其他Features(一对多关系)。每个Feature都有一个名称和一个重要状态(如果功能重要则为true,否则为false)。我想在TWIG中获得我产品的所有重要功能。下面的解决方案非常难看:Product:{{product.name}}Importantfeatures:{%forfeatureinproduct.features%}{%iffeature.important==true%}-{{feature.name}}{%endif%}{%endfor%}所以我想得到:Product:{{product.n

php - 将 Doctrine native 查询映射到无实体模型类

我正在尝试在Doctrine中使用native查询,现在创建了一些非常简单的东西:$rsm=newResultSetMapping();$rsm->addEntityResult('ObjectA','a');$rsm->addFieldResult('a','id','id');$query=$em->createNativeQuery('SELECT*FROMtablea',$rsm);我尝试使用此代码时收到错误消息,指出ObjectA不是有效的实体或映射的父类(superclass)。这是完全正确的。我的问题是:是否有任何方法可以使对任意类(不是实体)的native查询产生疯狂的

php - 使用 Laravel Doctrine 的 InvalidFieldNameException

我正在将我的ZendFramework1应用程序转换为Laravel应用程序。我使用的是Doctrine,所以我将模型移到了Laravel。我正在使用laravel-doctrine字段是用camelCase编写的,当通过doctrine创建数据库时,它们也是用camelCase创建的,如下所示:/***@ORM\Entity(repositoryClass="Repositories\Customer")*@ORM\Table(name="customers")*@ORM\HasLifecycleCallbacks*/classCustomer{/***@ORM\Id@ORM\Col

php - 未捕获的 PHP 异常 Doctrine\ORM\ORMException : "Unknown Entity namespace alias ' AppBundle'.“

我刚刚开始了我的第一个composer项目,想为它设置数据库和类。但是我被卡住了。我在prod.log中收到上述错误我在这里遵循了本教程:http://symfony.com/doc/current/book/doctrine.html我创建了数据库phpbin/consoledoctrine:database:create然后想创建一个实体phpbin/consoledoctrine:generate:entity当询问实体快捷方式名称时,我输入了AppBundle:Product然后创建数据库字段等。我收到了这条消息EntitygenerationGeneratingentityc