2010-11-19 63 views
0

我做了it但它沒有工作。Symfony推進多個數據庫錯誤

我創建:

propel.schema.xml

propel.schema.yml

# config/propel.schema.yml 
propel: 
    article: 
    id:   ~ 

另一分貝配置是

orgdb.schema.xml

<?xml version="1.0" encoding="UTF-8"?> 
<database name="orgdb" defaultIdMethod="native" noXsd="true" package="lib.model"> 
<table name="organization"> 
    <column name="id" type="INTEGER" primaryKey="true" required="true" autoIncrement="true"/> 

orgdb.schema.yml

# config/orgdb.schema.yml 
orgdb: 
    organization: 
    id:   ~ 
在database.yml中

# You can find more information about this file on the symfony website: 
# http://www.symfony-project.org/reference/1_4/en/07-Databases 

dev: 
    propel: 
    param: 
     classname: DebugPDO 
     debug: 
     realmemoryusage: true 
     details: 
      time:  { enabled: true } 
      slow:  { enabled: true, threshold: 0.1 } 
      mem:  { enabled: true } 
      mempeak: { enabled: true } 
      memdelta: { enabled: true } 

test: 
    propel: 
    param: 
     classname: DebugPDO 

all: 
    propel: 
    class:  sfPropelDatabase 
    param: 
     classname: PropelPDO 
     dsn:  mysql:dbname=db1;host=localhost 
     username: 
     password: 
     encoding: utf8 
     persistent: true 
     pooling: true 

    orgdb: 
    class:  sfPropelDatabase 
    param: 
     classname: PropelPDO 
     dsn:  mysql:dbname=db2;host=localhost 
     username: 
     password: 
     encoding: utf8 
     persistent: true 
     pooling: true 

我把這個命令

php symfony propel:build-model 

我沒問題買w母雞在我的網站,我看到的錯誤

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db1.organization' doesn't exist 

當我把這個命令:

php symfony propel:build --all 

在cmd中錯誤的是

Fatal error: Call to a member function addTable() on a non-object in C:\PHP...\lib\vendor\symfony\lib\plugins\sfpropelPlugin\lib\vendor\propel-generator\classes\propel\phing\PropelSQLTask.php on line 237 

什麼想法?

謝謝

回答

1

我解決了這個問題。

當您創建propel.schema.yml,propel.schema.xml,orgdb.schema.yml和orgdb.schema.xml時,您需要放置該包,因爲您不會將所有生成的東西放在同一個包中。然後,你可以在一個方案中(陽明和XML)或在兩個

在propel.schema.xml

<?xml version="1.0" encoding="UTF-8"?> 
<database name="propel" defaultIdMethod="native" noXsd="true" package="lib.model.propel"> 
    <table name="article"> 
    ... 

和propel.schema.yml添加它例如

# config/propel.schema.yml 
propel: 
    _attributes: {package: lib.model.propel} 
    article: 
    ... 

祝你好運。