我是symfony的新手。我现有的应用程序是在symfony1.4中开发的。他们没有使用任何数据库连接。现在我想在这个应用程序中创建新的MySQL数据库连接。
我该怎么做?
答案 0 :(得分:1)
all:
use_database: true
从控制台运行此命令
php symfony configure:database "mysql:host=dbhost;dbname=yourdbname" dbuser dbpassword
答案 1 :(得分:0)
请检查所有步骤以建立数据库连接symfony1.4
Step 1 :
file:config / ProjectConfiguration.class.php
find what:
---------
public function setup()
{
$this->enablePlugins('owCorePlugin');
}
Repalce with :
------------
public function setup()
{
$this->enablePlugins('owCorePlugin');
$this->enablePlugins('sfDoctrinePlugin');
}
Step 2 :
config/databases.yml
You need to create this file and add below code.replace caps letter with your details.You need to maintain same space also.
all:
教义: class:sfDoctrineDatabase PARAM: dsn:mysql:host = HOST_NAME; dbname = DB_NAME 用户名:USERNAME 密码:密码 第3步: 前端/配置/ settings.yml中
find what :
use_database: false
Replace with
use_database: true
Run the following command:
change the project configuration.Make sure you need to run this command in root folder of our project
php symfony configure:database --name = doctrine --class = sfDoctrineDatabase“mysql:host = HOST_NAME; dbname = DB_NAME”USERNAME PASSWORD
step 5: schema files
$ php symfony doctrine:build-schema
$ php symfony doctrine:build-model
$ php symfony doctrine:build-forms
$ php symfony doctrine:build-filters
$ ln -s lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/web web/sfDoctrinePlugin