草庐IT

doctrine

全部标签

php - Doctrine 多对多插入

我有一些问题。我正在研究并尝试所有建议,但没有一个工作。我最终得到:Argument1passedtoEntity\User::addCategories()mustbeaninstanceofEntity\Category,stringgiven,我有manytomany关系,用户,user_category和类别用户category=new\Doctrine\Common\Collections\ArrayCollection();}publicfunctiongetCategories(){return$this->categories;}publicfunctionaddCat

php - Doctrine 2 : What does getResult return when there are no rows? 无效?

我想知道像get*Result()这样的函数会返回什么。好像是null?我可以在文档的哪个位置找到此类信息? 最佳答案 get*Result()方法返回一个空的array()getSingle*Result()方法抛出一个\Doctrine\ORM\NoResultException这里是doctrineAPI文档的直接链接getResult()doctrineAPIdocsgetSingleResult()doctrineAPIdocsgetSingleScalarResult()doctrineAPIdocsgetOneOrNu

PHP 注释 : Addendum or Doctrine Annotation?

AddendumDoctrine2Annotations你能给我一个比另一个更好的理由吗?这是我现在的list:附录是一个专门用于此的项目附录似乎有更多的功能AddendumAPI似乎更易于使用Doctrine有更多的支持和更多的人参与Doctrine似乎是一个更有活力的项目Doctrine完全兼容PHP5.3,而Addendum似乎正试图变得兼容(参见主页)DoctrineAnnotations可以轻松缓存这个决定并不容易... 最佳答案 我想我宁愿使用Doctrine的组件:我从没听说过Addendum——虽然我听说过很多关于D

php - Doctrine 不允许 ResultSetMappingBuilder 工作

我正在使用Symfony2和doctrine。我已经设置了一个带有自定义查找功能的自定义存储库。当它连接到子查询时,根据我所读到的内容,我非常确定我需要使用ResultSetMappingBuilder从查询中获取结果。但我不断收到以下错误:Thecolumn'id'conflictswithanothercolumninthemapper.我的代码是:$sql="SELECTc.idascid,c.country,c.rank,c.continent,q.*FROMcountrycINNERJOIN(SELECTd.*,MAX(d.rating)ASmaxratingFROMduck

php - 带有 ManyToOne 字段的 Doctrine @UniqueEntity?

我正在尝试创建一个包含2个字段(都是ManyToOne字段)的UniqueEntity。代码如下:/**@ORM\Table()*@ORM\Entity*@ORM\HasLifecycleCallbacks()*@UniqueEntity(fields={"user","connect"})*/classUserConnect{/***@varinteger$id**@ORM\Column(name="id",type="integer")*@ORM\Id*@ORM\GeneratedValue(strategy="AUTO")*/private$id;/***@varboolean$

php - Symfony2 和 Doctrine : OneToMany relation duplicates data in the table

我有两个表:文章和电子邮件。电子邮件表将包含与特定文章相关的电子邮件,例如:id|article_id|email1|1|test@etest.com2|1|test2@test.com3|2|test@etest.com4|2|test3@test.com等等......article_id与articles表中的id存在关联。在我的实体中,我有这段代码:classArticles{..../***@ORM\OneToMany(targetEntity="\Acme\DemoBundle\Entity\Emails",mappedBy="articles")*/private$ema

php - 来自特定实体的 Symfony2 Doctrine 更新模式

如果我跑phpapp/consoledoctrine:schema:update--force它将从所有实体更新我的数据库。我只需要为用户实体更新数据库,解决方案是什么?一种解决方案是定义一个自定义实体管理器,然后将该实体管理器传递给phpapp/consoledoctrine:schema:update--force--em="custom"但也许它在不定义自定义实体管理器的情况下存在更快的东西? 最佳答案 根据命令文档,没有这样的选项。如果这是您只需要做一次的事情,我建议使用--dump-sql选项来获取所需的SQL指令,然后手

php - Doctrine 2.1 和表 utf-8 编码

有人能告诉我如何强制Doctrine使用UTF-8编码和utf8_polish_ci创建数据库表吗?我的Doctrine配置文件有这个数据库配置参数:$conn=array('driver'=>'pdo_mysql','dbname'=>'test','user'=>'root','password'=>'*****','charset'=>'utf8','driverOptions'=>array(1002=>'SETNAMESutf8'));尽管如此,它仍然使用默认编码创建表:latin1和latin1_swedish_ci。 最佳答案

php - 在 Symfony 2/Doctrine 2 实体中存储空间点?

Symfony2没有MySQL支持的空间点数据类型。我在Doctrine2文档中找不到关于这种特定数据类型的任何内容,所以,有人知道如何在Symfony2中使用点吗?另外,如何根据半径查询?谢谢!:) 最佳答案 最简单的方法是为空间数据类型实现自定义类型,然后声明自定义DQL函数以简化查询。我在这里写道:http://codeutopia.net/blog/2011/02/19/using-spatial-data-in-doctrine-2/ 关于php-在Symfony2/Doctr

php - 尝试生成实体时 Symfony2/Doctrine2 无效映射文件异常

我有一个非常简单的数据库,我正在尝试导入它并从中创建实体。Doctrine(Symfony)能够从数据库生成YML映射文件。但是当我随后尝试生成实体时,出现以下错误:[Doctrine\Common\Persistence\Mapping\MappingException]Invalidmappingfile'SandboxBundle.Entity.Product.orm.yml'forclass'SandboxBundle\Entity\Product'.yml文件对我来说看起来不错,因为我们期望它是由Doctrine生成的。为了确定,我根据在线yml验证器检查了它,它说它没问题。