草庐IT

Doctrine_RawSql

全部标签

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 - 动态目标实体 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.'.

php - Doctrine2 (Symfony4) 套接字上的数据库连接 url

我很难让数据库连接与Symfony4w/doctrine2中使用的mysqlurl格式一起工作。这是我正在尝试做的事情:mysql://dbusername:dbpassword@unix_socket(/path/to/socket)/dbname我做错了什么?请指教。Doctrine2文档对于通过套接字进行连接的格式并不清楚。 最佳答案 我在尝试对需要使用本地unix套接字的mysql使用google云平台SQL时也遇到了这个问题。URL的每一部分都不是强制性的,它的形式是:://[user[:password]@][host]

php - Doctrine:如何将对象列值标记为脏?

我有一个类型为object的列在模型中。但是如果我加载一个模型,并更改对象的一个​​属性,然后重新保存,它似乎并没有重新序列化该对象。例如$model_instance=$table->find(1);$object=$model_instance->object_column;$object->someProp='newvalue';$model_instance->save();//hasnoeffect我认为这是因为它通过使用!==比较旧值和新值来检查修改,这会返回false,因为它们都是对同一对象的引用。我可以在保存之前克隆该对象,但显然我错过了一种更明显的方法。

php - Doctrine 延迟加载

我刚刚开始掌握Doctrine,并使用建议的延迟加载模型。根据教程,我创建了一个DoctrineBootstrap文件:setAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE,true);$manager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING,Doctrine_Core::MODEL_LOADING_CONSERVATIVE);Doctrine_Core::loadModels(array(dirname(__FILE__).'/models/generated',dirn

php - 在 Doctrine 2.x ORM 中使用 REGEXP

我对此进行了大量研究,我确信答案是否定的,但我很乐意证明是错误的。我想执行一个用DQL编写的包含REGEXP操作的查询。例如:select*fromassetswherecampaign_id=1andfileNameREGEXP'godzilla*'orderbyfileNamedesc又名$builder->add('select','a.fileName')->add('from','\Company\Bundle\Entity\Asseta')->add('where','a.campaign=1')->...REGEXPMAGIC...->add('orderBy','a.f