我使用 Propel 作为我的 Symfony 项目的 DAL。我似乎无法让我的应用程序跨两个或更多数据库工作。
这是我的 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
这是数据库.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
当我调用php symfony propel-build-model
时,仅生成db1
,而不生成db2
。
知道如何解决这个问题吗?
最佳答案
I got this issue working !最重要的是您必须根据 %dbname%.schema.yml 命名您的模式。这样 Symfony 将能够将 yml 分配给正确的数据库。
关于symfony1 - Symfony 中的多个数据库支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/733224/