0

I'm new to symfony. My existing application is developed in symfony1.4. They didn't used any db connection. Now I want to create new MySQL database connection in this application.

How can I do that?

2 Answers 2

1
  1. in settings.yml

    all:
      use_database: true
    
  2. from the console run this command

    php symfony configure:database "mysql:host=dbhost;dbname=yourdbname" dbuser dbpassword
    
Sign up to request clarification or add additional context in comments.

3 Comments

Yes Thanks for your advice. Then how i should call that in action class.
@Manivasagan Don't forget to read the doc please.
No, just run it once from the console and, as just said by jOk, don't forget to read the doc
0

Please check all the steps to make db connection 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:

doctrine: class: sfDoctrineDatabase param: dsn: mysql:host=HOST_NAME;dbname=DB_NAME username: USERNAME password: PASSWORD Step 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 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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.