草庐IT

Doctrine_RawSql

全部标签

php - 有没有办法在 Doctrine ORM 中将 LIMIT 添加到 UPDATE 查询?

我正在使用Doctrine2.5.x,但在让LIMIT子句用于UPDATE查询时遇到了问题。它总是更新所有匹配的记录(即它似乎忽略了LIMIT子句)。setMaxResults()与UPDATE查询一起使用时似乎没有效果。作为一种快速解决方法,我正在使用nativeMySQL查询,但这不是最佳解决方案。我尝试了这些示例,但没有一个有效:DoctrineupdatequerywithLIMIThttps://recalll.co/app/?q=doctrine2%20-%20Doctrine%20update%20query%20with%20LIMIT带有setMaxResults()

php - 与 Doctrine Symfony 的条件关系

我需要在Symfony实体中创建这个数据库方案:A类:编号姓名...一些其他属性仅适用于A类B类:编号姓名...一些其他属性仅适用于B类C类:编号姓名...一些C类专用的其他属性类(class):编号姓名输入类(class)编号class_type[A,B,C]...我需要在类(class)实体(使用class_id)与其他实体(ClassA、ClassB、ClassC)(使用id)和使用class_type(A、B、C)之间创建关系。类(class)不是类(class),类(class)也不是类(class)。这里没有继承。在我的项目中,我使用了这个概念(id和type来映射不同的实

php - 将 Doctrine 与 Zend Framework 1.8 应用程序集成

我有兴趣将Doctrine用作我正在编写的新ZendFramework应用程序的ORM。我试图找出尽可能直接地集成它的最佳方法。我发现的每个示例都是不同的,其中很多早于ZF1.8中新的自动加载功能。他们都还没有为我工作。谁有好的方法吗?我倾向于将它放在我的Bootstrap文件中,但有些人建议制作一个Zend_Application_Resource插件。困难的部分似乎是让Doctrine命名空间和模型类的加载路径正常工作,默认情况下它们不遵循Zend自动加载约定。有什么想法吗?谢谢。 最佳答案 几周前,我为Doctrine和Zen

php - 如何使用 doctrine 在单个查询中获取整棵树?

此片段来自officialwebsite按预期工作:$treeObject=Doctrine::getTable('Category')->getTree();$rootColumnName=$treeObject->getAttribute('rootColumnName');foreach($treeObject->fetchRoots()as$root){$options=array('root_id'=>$root->$rootColumnName);foreach($treeObject->fetchTree($options)as$node){echostr_repeat(

php - Doctrine 查询中的括号

嗨我必须嵌套一些或/和条件但我的sql语句中需要括号才能按正确的顺序执行但是你是怎么做到的应该是这种形式(...或...)和...谢谢 最佳答案 根据这篇博文“SolvingtheDoctrineParenthesisProblem”,您需要执行一个$query->where("(ConditionAORConditionB)ANDConditionC");可能看起来像:Doctrine_Query::create()->from(...)->where('A=?ORB=?',array(valA,valB))->andWhere(

php - 为什么我的 doctrine2 实体中的对象类型在调用 persist() 和 flush() 时没有得到更新?

这是我正在做的:$entity=newMeta();$obj=newstdClass();$obj->foo=15;$obj->bar=0;$obj->bor=true;$entity->setObject($obj);$em->persist($entity);$em->flush();$entity=$entityRepository->find(1);var_dump($entity);返回:object(Jo\Model\Entity)[130]protected'id'=>int1protected'user'=>nullprotected'object'=>object(s

php - 使用 Doctrine ORM : Custom repository

我有大约10个实体:\App\Entity\User,\App\Entity\Group,...对于它们中的每一个都有自己的存储库:\App\Repository\UserRepository,...在十几种方法中的每一种中。访问方法在Doctrine中:$userRepository=$em->getRepository('App\Entity\User');但是,这并不方便,因为丢失了代码补全。问题:如何在不增加静态连接代码的情况下组织与存储库的工作?我应该使用静态方法get吗?classUserRepositoryextendsEntityRepository{/***@stat

php - 注释不同 Symfony 2/Doctrine 2

这两者有什么区别?/***@ORM\ManyToOne(targetEntity="Category",inversedBy="products",cascade={"remove"})*@ORM\JoinColumn(name="category_id",referencedColumnName="id")*/protected$category;和/****@ORM\ManyToOne(targetEntity="Category",inversedBy="products")*@ORM\JoinColumn(name="category_id",referencedColumnN

php - 类 Doctrine\ORM\PersistentCollection 的对象无法转换为字符串

我用Symfony2制作了一个Web应用程序,其中一个User有一个数组关联ManytoMany与实体Mission。用户可以通过表单上传实体$product,表单传递的数据之一是与用户相关的任务。当我尝试上传数据时,出现错误:ContextErrorException:CatchableFatalError:ObjectofclassDoctrine\ORM\PersistentCollectioncouldnotbeconvertedtostringinC:\BitNami\wampstack-5.4.23-0\frameworks\symfony\vendor\doctrine\

php - Doctrine DBAL Query Builder 缺少 insert() 方法

我觉得有那么一刻我错过了一些小东西;我在DotrineDBAL2.2.x/2.3.x上的QueryBuilder组件上使用insert()方法时遇到问题。我做了一些调查,这是来自QueryBuilderpagefromtheDBALDocumantation的片段The\Doctrine\DBAL\Query\QueryBuildersupportsbuildingSELECT,INSERT,UPDATEandDELETEqueries.Whichsortofqueryyouarebuildingdependsonthemethodsyouareusing.它继续解释代码示例,这样我就