propel.php文件需要用連接信息進行填充。請參閱以下示例:
<?php
return [
'propel' => [
'database' => [
'connections' => [
'bookstore' => [
'adapter' => 'mysql',
'classname' => 'Propel\Runtime\Connection\ConnectionWrapper',
'dsn' => 'mysql:host=localhost:3306;dbname=bookstore',
'user' => 'root',
'password' => '12345678',
'attributes' => []
],
'wordpress' => [
'adapter' => 'mysql',
'classname' => 'Propel\Runtime\Connection\ConnectionWrapper',
'dsn' => 'mysql:host=localhost:3306;dbname=wordpress',
'user' => 'root',
'password' => '12345678',
'attributes' => []
]
]
],
'runtime' => [
'defaultConnection' => 'bookstore',
'connections' => ['bookstore', 'wordpress']
],
'generator' => [
'defaultConnection' => 'bookstore',
'connections' => ['bookstore','wordpress']
]
]
];
請注意,我創建了2個連接。你可以創建儘可能多的你想要的。現在,如果有一個模式文件將它放在與propel.php文件相同的級別上。我把這兩個都放在項目的根目錄下,並且與vendor
目錄的級別相同。在同一級別創建一個model
目錄。然後運行以下命令:
~/Desktop/Propel_orm/vendor/bin/propel model:build --output-dir ~/Desktop/Propel_orm/models
你將不得不在models
目錄生成的模型文件。我在桌面上創建了示例項目。相應地更改路徑。
已在此處上傳代碼:https://github.com/dipu/Propel-ORM-Test – 2016-01-17 12:35:43