0

我是symfony的新手。我现有的应用程序是在 symfony1.4 中开发的。他们没有使用任何数据库连接。现在我想在这个应用程序中创建新的 MySQL 数据库连接。

我怎样才能做到这一点?

4

2 回答 2

1
  1. 在 settings.yml

    all:
      use_database: true
    
  2. 从控制台运行此命令

    php symfony configure:database "mysql:host=dbhost;dbname=yourdbname" dbuser dbpassword
    
于 2012-12-11T08:09:18.743 回答
0

请检查所有步骤以使数据库连接 symfony1.4

Step 1 :

文件:配置/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:

学说:类:sfDoctrineDatabase 参数:dsn:mysql:host=HOST_NAME;dbname=DB_NAME 用户名:USERNAME 密码:PASSWORD 第 3 步:frontend/config/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 配置:数据库 --name=doctrine --class=sfDoctrineDatabase "mysql:host=HOST_NAME;dbname=DB_NAME" 用户名密码

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
于 2013-03-01T10:59:46.727 回答