草庐IT

Doctrine_Query

全部标签

php - 深度克隆后未创建 Doctrine2 ManyToMany 记录

我遇到了以下问题。应用程序需要能够克隆一个Season实体及其所有相关实体。我在thisgreatquestion中受到启发-一切正常,但ManyToMany关系存在问题。请查看所附图片,其中描述了数据库图表的一小部分,显示了我遇到问题的部分。我想要实现的状态是将Price实体的克隆绑定(bind)到现有Offer实体。明确地说-我不能也不能克隆Offer实体,Price实体的新克隆实例必须绑定(bind)到主的同一实例价格实体实例绑定(bind)。克隆前offer_price表的示例内容offer_id|price_id----------+----------47|77克隆后off

php - 无法让 Codeception 在多站点上使用 wp_query

我正在尝试设置一个测试来计算数据库中自定义帖子的数量,作为更强大测试的第一步,但它无法正常工作。这是测试的副本:assertEquals(53,$query);}}在我的模型中,函数如下所示publicstaticfunctioncount(){$args=array('posts_per_page'=>-1,'offset'=>0,'post_type'=>'courses','suppress_filters'=>true,);$query=new\WP_Query($args);returncount($query->posts);}但是当它到达断言时,它说53不等于0。我在本地

PHP Doctrine : how to set refClass extra columns?

我有以下架构User:columns:id:type:integerprimary:truename:stringrelations:UserGroup:local:userGroup_idforeign:idrefClass:User2GroupUserGroup:columns:id:type:integerprimary:truename:stringrelations:User:local:user_idforeign:idrefClass:User2GroupUser2Group:columns:user_id:type:integerprimary:trueuserGrou

php - 在 doctrine 1.2 中使用禁止的列名

我正在使用postgresql数据库。我有一个名为“来自”的列的表(我无法更改它)。doctrine生成的sql插入查询是不正确的,因为列名“from”应该用引号括起来。我怎样才能让Doctrine做到这一点?我相信,有一种快速而干净的方法可以解决这个问题。提前致谢。 最佳答案 也许$conn->setAttribute(Doctrine_Core::ATTR_QUOTE_IDENTIFIER,true);?来自Docs->Configuration->Identifierquoting

php - Not a valid entity or mapped super class 错误来自 Doctrine

我正在尝试设置Doctrine(2.2.1)以与我的网站一起使用,并且我遵循了入门指南,但我收到以下错误:Fatalerror:Uncaughtexception'Doctrine\ORM\Mapping\MappingException'withmessage'ClassDocumentFieldisnotavalidentityormappedsuperclass.'inC:\inetpub\sites\hd\Doctrine\ORM\Mapping\MappingException.php:147Stacktrace:#0C:\inetpub\sites\hd\Doctrine\

php - Doctrine 获取加入

首先,我将给出一个带有一些伪代码的示例,然后我将解释问题所在。假设我有两个实体用户和电话号码。他们的关系是一对多的。在我的UserRepository中,我可以有类似的东西:classUserRepository{publicfunctiongetUser($id,$type){$users=$this->createQuery("SELECTu,pFROMUseruJOINu.phonenumberspWHEREu.id=:idANDp.type=:type")->setParameters(array('id'=>$id,'type'=>$type,))->getResult();

php - 整数字段上的 Doctrine 关系返回字符串

我的schema.ymlOrganisation:columns:id:{type:integer(4),notnull:true,unique:true,primary:true,autoincrement:true}name:{type:string(100),notnull:true,unique:true}parent_organisation_id:{type:integer(4),notnull:false}relations:ParentOrganisation:{class:Organisation,local:parent_organisation_id,foreig

PHP/MySQLi - fatal error : Call to a member function mysqli_query() on a non-object

这是我的代码:require"../include/functions.php";error_reporting(E_ALL);ini_set('display_errors','1');ConnectWithMySQLiDatabase();$Cat=addslashes($_POST["Category"]);$v=$conn->mysqli_query($conn,"SELECT*FROM`categories`WHERE`id`=$Cat");$vrowi=mysqli_fetch_array($v,MYSQLI_ASSOC);$url=$conn->real_escape_s

php - 动态目标实体 Doctrine 2 和 Symfony 2

我想要一个实体上的动态实体映射,该实体将被其他实体使用。例如,我有一个文件实体,它将存储MIME类型、映射key、name等,还有一个entity_id它将包含它所属的实体的id。映射key将确定类,因为此文件实体将是多对多的。所以File实体的targetEntity不是固定的。如何实现?文件实体产品实体namespaceAppBundle\Entity;useDoctrine\ORM\MappingasORM;/***Product**@ORM\Entity*/classProductextendsSuperClass{//....Othermappingproperties/**

php - Doctrine2 表达式 eq 用于匹配所有的特殊字符

我正在尝试使用doctrinequerybuilder运行过滤器,我正在使用expreq,但如果我没有过滤器值,我想为expreq使用一些特殊符号,它会返回所有行。我的代码:$q=$qb->select(array('p'))->from(payment::class,'p')->innerJoin(customer::class,'z','WITH','p.customer=z.id')->where($qb->expr()->eq('z.id','?2'))->setMaxResults($limit)->setFirstResult($offset)->orderBy('p.'.