草庐IT

Doctrine_RawSql

全部标签

php - Doctrine 查询内存使用情况

Doctrine似乎占用了超过4MB的RAM来执行一个简单的查询:printmemory_get_peak_usage()."\n";$q=Doctrine_Query::create()->from('Directoriesd')->where('d.DIRECTORY_ID=?',5);$dir=$q->fetchOne();print$dir['name']."".$dir['description']."\n";printmemory_get_peak_usage()."\n";/***************OUTPUT:**************************6

php - 带有别名的 SUM() 字段上的 Doctrine orderBy

我正在尝试做一个简单的Doctrine查询,但很费力。$query->select(array('app_title'=>'u.title','user_name'=>'u.user_name','first_used'=>'MIN(u.creation_time)','last_used'=>'MAX(u.stop_time)','total_usage'=>'SUM(u.stream_seconds)',))->from(self::USAGE_TABLE,'u')->orderBy('total_usage','DESC');很明显,我得到一个关于列名未知的错误,因为Doctri

php - Symfony2 - Doctrine - 有没有办法在一行中保存实体?

为了用教义拯救实体我应该这样做$em=$this->getDoctrine()->getEntityManager();$em->persist($product);$em->flush();但也许我可以用某种方式在一行中做到这一点$product->save();或$this->saveEntity($product);或$this->getDoctrineEntityManager()->persistAndFlush($product);如果我需要自己创建这个方法,那么如何以symfony的方式做到这一点? 最佳答案 pers

php - simplexml_load_file() : I/O warning : failed to load external entity "/user-bundle/Resources/config/doctrine/model/User. orm.xml

我的Symfony2生产部署有一些问题,我尝试了很多解决方案,但没有一个奏效。在生产环境中访问我的symfony应用程序时随机出现此错误:(!)Fatalerror:Uncaughtexception'Symfony\Component\Debug\Exception\ContextErrorException'withmessage'Warning:simplexml_load_file():I/Owarning:failedtoloadexternalentity"/home/user/symfony/vendor/friendsofsymfony/user-bundle

php - Doctrine2 多对多自引用

我在坚持多对多自引用关系时遇到了问题。我收到错误:Theclass'Doctrine\ORM\Persisters\ManyToManyPersister'wasnotfoundinthechainconfigurednamespaces当我删除与他们一起保存的所有子表单项时,就会发生这种情况。至少留下一个不会让错误发生。此外,如果我最初保存没有child的实体,一切正常。/***West\AlbumBundle\Entity\Album**@ORM\Table(name="albums")*@ORM\Entity(repositoryClass="West\AlbumBundle\E

php - Doctrine 2 自定义 ObjectMultiCheckbox 值

如何使用DoctrineModule\Form\Element\ObjectMultiCheckbox自定义值?我使用了Zend\Form\Element\MultiCheckbox并设置了如下值:$this->add(array('type'=>'Zend\Form\Element\MultiCheckbox','name'=>'countries','options'=>array('label'=>'Selectcountries','value_options'=>array('value'=>1,'label'=>'UnitedKingdom','continent'=>'E

php - Symfony2/Doctrine2 : Generate entities that are outside a bundle

我正在尝试为我的Symfony2应用程序生成实体。这些实体将由多个包(可能还有多个应用程序)共享,因此我不希望它们属于一个包。我希望它们位于src/MyApp/Entity文件夹中。我已经有了我的实体的YML,存储在src/MyApp/Entity/config/doctrine(class1.orm.yml,...)我正在尝试使用doctrine:generate:entities任务生成相应的PHP类这是我的app/config/config.yml中的内容orm:auto_generate_proxy_classes:%kernel.debug%auto_mapping:fals

php - 检查 Doctrine2 中是否存在关系的技术

我似乎无法在Doctrine文档中找到任何关于如何检查一个实体是否与另一个实体存在关系的提及:http://www.doctrine-project.org/docs/orm/2.0/en/reference/working-with-associations.html在Doctrine1.x中有一个名为exists的方法,可以在实体上调用它来检查:http://www.doctrine-project.org/documentation/manual/1_2/en/working-with-models#dealing-with-relations:clearing-related-

php - 如何使用 Doctrine 的 ArrayCollection::exists 方法

我必须检查ArrayCollection中是否已经存在Email实体,但我必须对作为字符串的电子邮件执行检查(该实体包含一个ID和一些与其他实体的关系,因此我使用一个单独的表来保存所有电子邮件。现在,首先我写了这段代码:/***AnewEmailisadding:checkifitalreadyexists.**Inanormalscenarioweshoulduse$this->emails->contains().*ButitispossibletheemailcomesfromthesetPrimaryEmailmethod.*Inthiscase,theobjectiscrea

php - 是否值得将 Doctrine 2 与 Zend Framework 一起使用?

我知道有些用户在ZendFramework中使用Doctrine2而不是Zend_Db。但我不知道为什么。为什么Doctrine2比Zend_Db好而Zend_Db不好?谢谢 最佳答案 (7-Mar-2013)免责声明:这个答案现在可能有点过时了。我目前没有跟上PHP社区的步伐,这个比较是在DoctrineORMv2和ZendFrameworkv1之间进行的。这是苹果与橙子的比较,因为它们是两种不同的东西。开箱即用的Zend_Db更像是PDO之上的一个增强型数据库抽象层,而Doctrine2是一个对象关系映射器(它位于它自己的DBA