草庐IT

doctrine

全部标签

php - Doctrine2 映射 : 2 fields mapped to one field (ManyToOne)

我有2个实体,即Match和Team。一个团队可以有一对多的比赛。但是,我的Match实体常量包含2个引用同一实体Team的字段。它们是$homeTeam和$awayTeam。如何将团队中的相同字段$matches引用为双向关系?我当前的非工作代码如下:我的匹配实体:/***@ORM\Entity*@ORM\Table(name="match")**/classMatch{/***@ORM\ManyToOne(targetEntity="Team",inversedBy="matches")*@ORM\JoinColumn(name="home_team_id",referencedC

php - 如何限制 Doctrine2 中的关联实体结果?

我有以下查询:$query=$this->getEntityManager()->createQuery('SELECTu,p,mFROMMyCoreBundle:UseruJOINu.programmespJOINu.motivationm');$result=$query->getResult();我想限制为每个用户返回的动机对象是我在其他地方使用的第二个查询的结果(在动机存储库上):$query=$this->getEntityManager()->createQuery('SELECTmFROMMyCoreBundle:MotivationmWHEREm.user=:userO

php - Doctrine2 - 无法删除具有单向 oneToMany 关系的实体

在尝试删除包含单向一对多关联的实体时,我遇到了外部约束冲突。我有以下简单的类:classDealer{/***@ManyToMany(targetEntity="Car",cascade={"persist","remove"})*@JoinTable(name="dealer_cars",*joinColumns={@JoinColumn(name="dealer_id",referencedColumnName="id")},*inverseJoinColumns={@JoinColumn(name="car_id",referencedColumnName="id",unique

php - 需要帮助理解 Doctrine 多对多自引用代码

我无法破译来自doctrinedocumentation的这段代码/**@Entity*/classUser{//.../***@ManyToMany(targetEntity="User",mappedBy="myFriends")*/private$friendsWithMe;/***@ManyToMany(targetEntity="User",inversedBy="friendsWithMe")*@JoinTable(name="friends",*joinColumns={@JoinColumn(name="user_id",referencedColumnName="id

php - 没有外键约束的 Doctrine 2 关联

我正在将遗留的PHP应用程序转换为Symfony2。目前应用程序数据不是很一致,所以我想避免创建外键约束。我的“产品”实体类中有以下注释:classProduct{//somedefinitions/***@ORM\ManyToOne(targetEntity="Manufacturer")*@ORM\JoinColumn(name="manufacturer_id",referencedColumnName="id")*/private$Manufacturer;}当我执行app/consoledoctrine:schema:update时,我得到了SQL命令ALTERTABLEpr

php - Doctrine 2.1 - DateTimeType 错误

我正在尝试通过Doctrine2.1项目将用户添加到我的数据库中,但我遇到了这种错误:Fatalerror:Calltoamemberfunctionformat()onanon-objectinC:...\Doctrine\DBAL\Types\DateTimeType.phponline44数据库表本身创建没有问题。我的以下代码可能有什么问题?registration_date=date("Y-m-dH:i:s");}publicfunctiongetId(){return$this->id;}publicfunctiongetLogin(){return$this->login;

php - Symfony2 : How to convert 'Doctrine->getRepository->find' from Entity to Array?

我想返回一个包含记录信息的\Symfony\Component\HttpFoundation\JsonResponse,但我需要将它作为数组传递。目前我这样做:$repository=$this->getDoctrine()->getRepository('XxxYyyZzzBundle:Products');$product=$repositorio->findOneByBarCode($value);但现在$product是一个实体,包含我想要的所有内容,但作为对象。如何将它们转换为数组?我在某处读到我需要使用“Doctrine\ORM\Query::HYDRATE_ARRAY”,

php - 使用 doctrine/dbal 使用 laravel 迁移重命名列名给出错误

我正在尝试重命名本地主机中的数据库列,以便以后可以在开发和生产中执行此操作我使用的是laravel5并安装了doctrinedbal。我的迁移代码:$table->renameColumn('puesto','aux');在我运行phpartisanmigrate之后它告诉我[Doctrine\DBAL\DBALException]Unknowndatabasetypejsonrequested,Doctrine\DBAL\Platforms\PostgreSqlPlatformmaynotsupportit.我尝试重命名的列甚至不是json,尽管表中有json列,但实际上只有一个名为

php - 我可以在 Doctrine2 中迭代实体的属性吗?

我用$myblogrepo=$this->_doctrine->getRepository('Entities\Blog')->findBy(array('id'=>12);我通过访问foreach($myblogrepoas$key=>$value){echo$key.$value;}如何获取字段名称?我认为key=>可以工作,但它打印skey为0所以我认为这会起作用:foreach($myblogrepo[0]as$key=>$value){echo$key.$value;}可是什么都没有 最佳答案 很可能,您的博客实体的属性被

php - 在 Doctrine PHP Symfony 中覆盖 Doctrine_Record (sfDoctrineRecord) 实例方法

我的背景是Propel,所以我希望在Doctrine_Record(sfDoctrineRecord)中重写一个神奇的getter是一件简单的事情,但是我得到了一个段错误或者重写方法被简单地忽略了有利于父类(superclass)中的一个。https://gist.github.com/697008eaf4d7b606286aclassFaqCategoryextendsBaseFaqCategory{publicfunction__toString(){return$this->getCategory();}//doesn'twork//overridegetDisplayNamet