Multiple databases support in Symfony

Posted by Ngu Soon Hui on Stack Overflow See other posts from Stack Overflow or by Ngu Soon Hui
Published on 2009-04-09T07:42:37Z Indexed on 2010/06/15 9:12 UTC
Read the original article Hit count: 175

Filed under:

I am using Propel as my DAL for my Symfony project. I can't seem to get my application to work across two or more databases.

Here's my schema.yml:

db1:
  lkp_User:
    pk_User:                     { type: integer, required: true, primaryKey: true, autoIncrement: true }
    UserName:                    { type: varchar(45), required: true }
    Password:                    longvarchar
    _uniques:
      Unique:                    [ UserName ]

db2:
  tesco:
    Id:                  { type: integer, required: true, primaryKey: true, autoIncrement: true }
    Name:                { type: varchar(45), required: true }
    Description:         longvarchar

And here's the databases.yml:

dev:
  db1:
    param:
      classname: DebugPDO
test:
  db1:
    param:
      classname: DebugPDO
all:
  db1:
    class: sfPropelDatabase
    param:
      classname: PropelPDO
      dsn: 'mysql:dbname=bpodb;host=localhost'   #where the db is located
      username: root
      password: #pass
      encoding: utf8
      persistent: true
      pooling: true


  db2:
    class: sfPropelDatabase
    param:
      classname: PropelPDO
      dsn: 'mysql:dbname=mystore2;host=localhost'   #where the db is located
      username: root
      password: #pass
      encoding: utf8
      persistent: true
      pooling: true

When I call php symfony propel-build-model, only db1 is generated, db2 is not.

Any idea how to fix this problem?

© Stack Overflow or respective owner

Related posts about symfony