草庐IT

doctrine

全部标签

php - Doctrine 和 Symfony 2 中的 DateTime 字段

我是Symfony2的新手,并设置了一个表单以通过Doctrine将日期时间数据输入MySQL数据库,但我收到以下错误:Theform'sviewdataisexpectedtobeoftypescalar,arrayoraninstanceof\ArrayAccess,butisaninstanceofclassDateTime.Youcanavoidthiserrorbysettingthe"data_class"optionto"DateTime"orbyaddingaviewtransformerthattransformsaninstanceofclassDateTimeto

php - symfony2 动态数据库连接使用 Doctrine

我正尝试在Symfony2中使用doctrine建立多个数据库连接,但无法做到。我在Google和堆栈溢出中进行了广泛搜索,但到处都是通过config.yml文件或动态数据库完成的,其中所有数据库都具有相同的架构/实体。但就我而言,数据库是根据子域确定的,并且所有子域的数据库架构都不相同。例如:test1.example.com=>应该加载test1dbtest2.example.com=>将加载test2数据库test1和test2DB不同,它们都是在DB级别创建的,并且在doctrine中没有实体条目。任何人都可以帮助我如何在Symfony2中做到这一点。

php - Doctrine 查询语言获取每组最大/最新行

我正在尝试将相对简单的SQL语句转换为可在Doctrine中运行的SQL语句,但未能成功。这是SQL语句,在针对我的数据库运行时按要求工作:SELECTa.*FROMscoreaINNERJOIN(SELECTname,MAX(score)AShighestFROMscoreGROUPBYname)bONa.score=b.highestANDa.name=b.nameGROUPBYnameORDERBYb.highestDESC,a.dateCreatedDESC这是迄今为止的DQL尝试:$kb=$em->createQuery("SELECTaFROMShmupBundle:Sco

php - 如何在 symfony/doctrine 上使用 SSL 连接到 MySQL

我正在尝试连接到启用了SSL的MySQL。我正在使用Symfony2框架和Doctrine。在纯PHP中,我可以用$link=mysql_connect("127.0.0.1:3306","test","testpass",true,MYSQL_CLIENT_SSL);有谁知道我如何在symfony/doctrine中做到这一点?config.yml中正确的Doctrine配置是什么?更新:也许我的问题是“config.yml中正确的Doctrine配置是什么?”是错的。那么,我该怎么做呢?我应该从哪里开始?谢谢 最佳答案 在Doc

php - Symfony 3 Doctrine 组合键 : single id is not allowed on composite primary key in entity

我有一个实体integercolumn(compositeId)和一个stringcolumn(asin)我希望两列都作为复合键使用。所以我在文档中查看:http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/composite-primary-keys.html但是当我尝试加载我的存储库时$myEntity=$em->getRepository(MyEntity::class);我收到此错误消息:singleidisnotallowedoncompositeprimarykeyinentit

php - 调用 "doctrine create-db"时找不到驱动程序

我不知道为什么,但是,我无法使用doctrinecreate-db执行此命令。如您所见,我的pdo和pdo_mysql已激活。php-i|grep'ini'ConfigurationFile(php.ini)Path=>/etc/php5/cliLoadedConfigurationFile=>/etc/php5/cli/php.iniScanthisdirforadditional.inifiles=>/etc/php5/cli/conf.dadditional.inifilesparsed=>/etc/php5/cli/conf.d/gd.ini,/etc/php5/cli/con

php - Doctrine:不能为子查询分配别名

我有一个Doctrine查询,它在选择中有一个子查询,以便从另一个表中获取一个字段(并摆脱繁重的左连接)。问题是Doctrine返回给我的别名不是我想要的,因此我很乐意自定义它们。这可能吗?这是我的查询:$query->select("id,page_id,status,title,"."segment,url,current_user_id,"."current_user_last_action_time,pt.name,")->addSelect("(SELECTs.usernamefromsfGuardUserswhereid=current_user_id)")->innerJ

mysql - DQL 和等效 SQL 不返回相同数量的结果集

这是我的Doctrine查询运行代码:$queryString="SELECTct,count(ct.id),IDENTITY(a.service)"."FROMConnectionTriplect"."JOINct.account_connectionac"."JOINAccountaWITH(a=ac.account_1ORa=ac.account_2)"."GROUPBYa.service,ct.property,ct.value";$query=$em->createQuery($queryString);//echo$query->getSQL();$results=$que

php - 无法更改 Doctrine 连接

我正在尝试构建一个脚本,将项目从生产数据库导入到本地数据库,但在将连接形式的生产切换到本地时遇到问题。Doctrine_Manager::getInstance()->setCurrentConnection('prod-slave');//executequerytogetdatafromproduction,confirmitworkedDoctrine_Manager::getInstance()->setCurrentConnection('local');//insertdataintolocaldatabase当我运行它时,出现了这个错误:PHPFatalerror:Unc

php - 如何生成周表并按天和小时拆分

首先要明确;有这样一个例子:我可以用这个查询得到类(class):$qb->select("c")->from("ATLReservationBundle:Course","c")->where("WEEK(c.courseDate,1)=WEEK(CURRENT_DATE(),1)")->orderBy("c.courseDate","ASC");查询结果:{"courses":[{"id":110,"name":"Pilates","quota":8,"course_date":"2015-08-31T12:15:00+0000","studio":{"id":2,"name":"