草庐IT

Doctrine_Collection

全部标签

mysql - 如何在 doctrine2 queryBuilder 中实现 ON ( ... OR ...) mysql 查询

我在MYSQL中有一个SQL查询:例如SELECTs.*FROMvplanning.citiesasc1INNERJOINvplanning.citiesasc2ON(c1.id=c2.area_id)INNERJOINvplanning.storagesassON(s.city_id=c2.idORs.city_id=c1.id)WHEREc1.id=109;在原则上我可以写这样的东西(来self的工作代码):$query=$em->getRepository('VplanningPageBundle:Storage')->createQueryBuilder('s')->inner

php - 优化 Doctrine 查询以防止额外查询

我正在构建一个有更新墙的系统,您只能在其中看到好友的帖子。此处的“friend”按一组两个用户分类,这两个用户各自将彼此添加到他们的friend列表中。好友关联由DoctrineManyToMany关联处理,非常简单,如下所示:用户.php//..otherdeclarations/***@varArrayCollection*@ORM\ManyToMany(targetEntity="User")*@ORM\JoinTable(name="user_friends")*/protected$friends;//..moreunrelatedstuff并在我的查询中获取用户friend

php - 设置相等运算符的 Doctrine 更新查询

我在根据语句设置值时遇到问题我想激活一个特定的uc并停用所有其他ucs。(uc.collection=:collectionId)应返回true或false,以便正确处理。查询生成器:$queryBuilder=$this->getEntityManager()->createQueryBuilder();$queryBuilder->update('TestBundle:UserCollection','uc')->set('uc.active','(uc.collection=:collectionId)')->where('uc.user=:userId');$queryBuil

php - DQL 与 JOIN Doctrine2 和 Symfony2

您好,我有两个表:产品和库存。他们有manyToOne关系,看起来是这样的:库存:+------------+--------------+------+-----+---------+----------------+|Field|Type|Null|Key|Default|Extra|+------------+--------------+------+-----+---------+----------------+|id|int(11)|NO|PRI|NULL|auto_increment||stock_name|varchar(255)|NO||NULL|||address

mysql - 如何在doctrine中进行复杂的SQL查询

我有2个表:用户和他们的积分。用户有字段:编号姓名点有字段:编号开始日期结束日期count_of_points用户ID所以有些用户可能有积分也可能没有积分。点数条目受时间间隔限制(从开始日期到结束日期),并包含用户在此间隔内拥有的点数。我需要显示此时按总点数排序的用户表(时间戳必须在开始日期和结束日期之间)并稍后在View中显示此总和值。如果用户没有积分,则此计数必须等于0。我有这样的东西:$qb=$this->getEntityManager()->getRepository('MyBundle:User')->createQueryBuilder('u');$qb->select(

php - 如何防止 EntityManager (Doctrine Association) 删除

我遇到了以下问题:我有一个与客户一对一、单向关联的实体查询:/***@varCustomer**@ORM\OneToOne(targetEntity="Customer",cascade={"persist"},fetch="EAGER")*@ORM\JoinColumn(name="Customer",referencedColumnName="id",onDelete="SETNULL",nullable=true)*/protected$customer;如果我通过数据库后端(PhpMyAdmin)删除客户,那么一切都很好:客户字段设置为空,但如果我使用EntityManager

mysql - Doctrine 想要 "ALTER TABLE coo_users CHANGE id id VARCHAR(255) NOT NULL;"但每次我更新模式时都想这样做

如果我执行bin/consoledoctrine:schema:update--force结果是:Updatingdatabaseschema...Databaseschemaupdatedsuccessfully!"1"querywasexecuted每次运行update命令时都会执行此操作。因此,使用bin/consoledoctrine:schema:validate我看到了:[Mapping]OK-Themappingfilesarecorrect.[Database]FAIL-Thedatabaseschemaisnotinsyncwiththecurrentmappingf

php - Symfony 中的 Doctrine\ORM\Mapping\MappingException

我得到的完整错误是:[Doctrine\ORM\Mapping\MappingException]Property"followed"in"BackendBundle\Entity\Following"wasalreadydeclared,butitmustbedeclaredonlyonce当我尝试在我的BackendBundle中创建实体时。我在MYSQL中有3个表“empresas”、“tecnicos”、“profesionistas”,下面是每个表的fkCREATETABLEfollowing(idint(255)notnullauto_increment,userint(2

mysql - 使用 collection_select 按 user.id 过滤表单下拉列表

我的第一个SO帖子。终于找到了让我感到困惑的东西,在6个多小时后,我决定在我失去理智之前需要一些帮助。我正在尝试将collection_select用于字段中的下拉列表,以在第二个模型中创建新记录。我的目标是填充单个用户从帐户模型(一个共享数据库)创建的记录列表,以一种形式在名为Assets的新模型中创建记录。我已将帐户表单设置为为创建条目的用户存储自动生成的记录ID,因此我应该能够以某种方式引用它。此时,数据会填充到下拉列表中并可以保存,但它会显示所有用户创建的所有条目,而不仅仅是创建新条目的用户所做的条目。我确定有一些方法可以按current_user.id进行过滤。我尝试了100

mysql - Doctrine 选择 innerJoined 实体或没有关联的实体

我有以下与用户和地址相关联的模型:User-id-email-passwordAddress-id-street-zip_code-city-user_idOneuserhas[0:n]Address:users(id,email,password)======================================|1|"someone1@example.org"|"..."||2|"someone2@example.org"|"..."||3|"someone3@example.org"|"..."||4|"someone4@example.org"|"..."||5|"s