Using symfony with postgresql

Deadly 提交于 2019-12-24 03:14:17

问题


I am trying to create a website using Symfony and PostgreSQL. I cant find any documentation that shows how to do this. All the documentation assumes the backend db is mySQL.

Anyone knows how to do this?


回答1:


If you are using Doctrine, just use a dsn for pgSQL in your databases.yml, like this :

pgsql:dbname=testdb;host=127.0.0.1

It use the PDO syntax. Check the Doctrine documentation and PDO documentation.




回答2:


Symfony uses 3rd-parties ORMs for DB communication which provide abstraction layer over RDBMS specific architecture. Basically everything you have to do is to change Doctrine's/Propel's driver name, so in /config/databaes.yml set pgsql instead of mysql and you're done.




回答3:


The full answer (took me about an hour to figure this out) is:

  1. Modify database.yml as described here (see under Propel or Doctrine)
  2. (assuming you're using the Propel ORM like I am) Modify propel.ini as shown below (undocumented AFAIK)

Look for a section in your propel.ini names ;mysql options

comment the mysql options out - otherwise the generated SQL is a mix of postgresql and mysql - which confuses the hell out of psql.



来源:https://stackoverflow.com/questions/2840061/using-symfony-with-postgresql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!