草庐IT

Doctrine_Query

全部标签

php - Laravel 社交名媛错误 : "An active access token must be used to query information about the current user."

我正在使用Socialite通过Facebook验证我的用户。但是,我无法让它工作。我关注了this教程,但出现以下错误:我到处看了看,什么都试过了,但我无法让它工作。这是我的代码:在services.php中:'facebook'=>['client_id'=>'[MyAppID]','client_secret'=>'[MyAppSecret]','redirect'=>'http://localhost:8000/auth/facebook/callback/',],我的路线:Route::group(['middleware'=>['web','requestlog']],fu

php - Zend Framework 1.9 和 Doctrine 集成

我正在尝试设置ZendFramework和Doctrine。之前有关于ZF1.8的讨论IntegrateDoctrinewithZendFramework1.8app该讨论没有考虑AutoLoader/Bootstrap系统。如果我用./zh.sh生成一个应用程序框架,我将如何集成Doctrine。 最佳答案 找到解决方案http://pastie.org/481635http://pastie.org/481633在application/configs/application.ini中设置自动加载器和插件路径:autoloade

php - 使用 Doctrine 获取随机记录

我想知道如何从一个组中获得随机数量的成员,但我不知道最好的方法是什么,而且我认为ORDERBYRAND()不是最好的或者,由于一个组可以有超过100,000个成员,执行这种类型的查询可能会非常慢。我发现这种使用SQL的方法,但我不知道如何在DQL中做同样的事情:HowcanioptimizeMySQL'sORDERBYRAND()function? 最佳答案 为了不降低性能,我通常会这样做://RetrievetheEntityManagerfirst$em=$this->getEntityManager();//Getthenum

php - pg_query_params 返回错误 : bind message supplies 2 parameters, 但准备语句 ""需要 1

$Query=pg_query_params($db,'SELECTusernameFROMusersWHEREid=$1ANDpassword=(crypt(\'$2\',password))LIMIT1',array(33,'thepassword'));“绑定(bind)消息提供2个参数,但准备语句”“需要1”问题似乎围绕“$2”参数,heredoc字符串不起作用。建议? 最佳答案 单引号在SQL中用于字符串文字。这意味着:'$2'只是一个包含字符$和2而不是占位符的字符串。如果你想要一个占位符,你需要省略引号:$Query=

php - Doctrine 2 : Can entities be saved into sessions?

将实体保存到PHPsession后,延迟加载出现问题。有什么解决方法吗? 最佳答案 参见SerializingEntities在Doctrine手册中:(您在session中保存的所有内容都被序列化和反序列化。)Serializingentitiescanbeproblematicandisnotreallyrecommended,atleastnotaslongasanentityinstancestillholdsreferencestoproxyobjectsorisstillmanagedbyanEntityManager.

php - 如何在 Doctrine 中使用 "comment out"注释条目

给定以下带有PHPDoc注释的属性,其中包含Doctrine的注释:/***@ORM\Column(name="id",type="integer")*@ORM\Id*@ORM\GeneratedValue(strategy="AUTO")*/private$id;“注释掉”注释行之一的最佳方法是什么?例如像这样:/***@ORM\Column(name="id",type="integer")*@ORM\Id*//Commentoutplease//@ORM\GeneratedValue(strategy="AUTO")*/private$id;这样做是否有受支持的方式或一般惯例?

php - 如何使用 KNPPaginatorBundle 对使用 Doctrine Repository 的结果进行分页?

我正在做一个Symfony2项目,我决定使用KNPPaginatorBundle来构建一个简单的分页系统。所以我创建了一个Product实体,我想将分页器添加到indexAction操作(由CRUD命令生成)。//Retrievingproducts.$em=$this->getDoctrine()->getManager();//$entities=$em->getRepository('LiveDataShopBundle:Product')->findAll();$dql="SELECTaFROMLiveDataShopBundle:Producta";$entities=$em

php - 我怎样才能在 Doctrine 中将 NULL 设置到表中

我有一些表store_section(id,parent_id,label),我想更改一些行,设置parent_id=null。我想:$record=$table->getTable()->find($id);$record->parent_id=null;$record->save();但这行不通。如何在Doctrine中将NULL设置到表中,在上面的示例中,parent_id变为=0(不是=NULL)?感谢回复! 最佳答案 我会尝试以下方法之一:1:$record=$table->getTable()->find($id);$r

php - 删除 Doctrine 中的记录

我想在Doctrine中删除一条记录,但我不知道为什么它不删除。这是我的代码:functiondel_user($id){$single_user=$entityManager->find('Users',$id);$entityManager->remove($single_user);$entityManager->flush();}另外:我如何回显查询以查看这里发生了什么? 最佳答案 这是一个老问题,似乎还没有答案。作为引用,我将其留在此处以供更多引用。您也可以检查doctrinedocumentation要删除记录,您需要(

php - 选择一列 Doctrine DQL

我需要一个简单的表格列。以表“project”为例,包含列id、name和year。如果我这样做:$q=Doctrine_Query::create()->select('a.pro_id')->from('fndr_proyectoa')->where('a.pro_id=?',1);$pro=$q->execute();json_encode($pro->toArray());答案全是列样{"id":1,"name":"Projectname","year":2013}但我只需要一栏。我希望:{"id":1}它适用于DQL,因为原生SQL可以正常工作。ORM是使用VisualPar