草庐IT

Doctrine_Record

全部标签

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

php - Doctrine 不映射来自 FOSUserBundle 用户类的字段

当从FOSUserBundle继承User-Class时,doctrine将无法识别基User类的继承属性。只有我自己的类的属性才会用于创建/更新数据库模式。这是config.yml:配置文件:doctrine:orm:auto_generate_proxy_classes:"%kernel.debug%"naming_strategy:doctrine.orm.naming_strategy.underscoreauto_mapping:truemappings:FOSUserBundle:~AppBundle:~fos_user:db_driver:ormfirewall_name

php - Symfony/Doctrine - createQueryBuilder orderBy

我有一个“团队”实体,其属性为“预算”。我只想打印团队属性,我希望预算最高的团队出现在第一位、第二位、第三位...(DESC)。但是使用这段代码,它不起作用,我不明白为什么。indexAction(Controller)$em=$this->getDoctrine()->getManager();$teams=$em->getRepository('FootballBundle:Team')->getAllTeamsSortedByDescBudget();return$this->render('FootballBundle:Default:index.html.twig',arra

php - Symfony/Doctrine 中的动态数据库和模式创建

我想在静态数据库中存储数据库连接。根据需要,我想创建一个新数据库,将凭据存储在我的静态数据库中,然后根据现有实体在新数据库中创建模式。我知道如何使用symfony的命令行工具来做到这一点。我的目标是让它在服务中工作。我查看了Doctrine文档并尝试让一些东西起作用:$conn=$this->getDoctrine()->getConnection()->getSchemaManager()->createDatabase($dbname);$isDevMode=true;$config=Setup::createAnnotationMetadataConfiguration(arra

php - Doctrine——选择所有字段并按其中一个分组

我正在尝试使用doctrine创建一个查询,它基本上应该类似于SQL中的查询:SELECTp.*FROMsome_tabelASpGROUPBYp.type;所以我最终得到了这个,因为这是我发现的最接近的记录:privatefunctiongetAll(){//$this->em=>EntityManagerreturn$this->em->createQueryBuilder()->select('p')->from('AppBundle:Robots','p')->groupBy('p.type')->getQuery()->getResult(Query::HYDRATE_ARR