symfony1 - Symfony 中的多个数据库支持

标签 symfony1

我使用 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/

相关文章:

php - 如何在 symfony 中比较 Doctrine 和 Propel

php - 使用 Symfony/Doctrine 的 Memcache 正在重新加载数据

model-view-controller - 访问模型中的 Symfony 用户 session (Doctrine)

php - 如何在 Propel 中使用 MySQL 函数

symfony1 - Symfony Doctrine versionnable行为忽略字段

ubuntu - Symfony 应用程序不发送邮件(邮件未送达)

php - Symfony 与电子商务网站的其他框架

symfony1 - Symfony 表单 : how to change default widget for form generation

php - 在不影响内存限制的情况下导入巨大的 JSON 编码数组

php - 什么IDE对Symfony框架的支持最强?