Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
171 views
in Technique[技术] by (71.8m points)

symfony1 - Multiple databases support in Symfony

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I got this issue working! The most important thing is you must name your schema according to %dbname%.schema.yml. In this way Symfony will be able to assign the ymls to the correct database.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...