CATEGORY: Yii- Connecting To DB

Making DB Connection

Connecting to Database

To make a DB connection follow the below steps:

  • Open the application configuration file
    /testApplication/protected/config/main.php

  • Add or Uncomment
    • Uncomment this

    returnarray(

          ……

          ‘components=>array(

             ……

            ‘db=>array(

               connectionString=>‘mysql:host=localhost;dbname=dbname,

    username’ => ‘username,

    password’ => ‘password,

               ‘charset’ => ‘utf8’,

                ),

        ),
    …….
    );
    Please give appropriate connection string, user-name and password.

There are no more results.