Common Yii questions

Comparing #12 with #13

Revision #13 was created by GoofyX GoofyX on Oct 18, 2011, 8:47:26 AM.

Typo fixed.

Content

[...]
<hr/>

### How to connect to database in controller?

#### Answer:
The best approach is to set db con
enection in your main.php config.

The second one would be just using the CDbConnection::__construct

Examples for both aproaches can be found here
[Guide::Establishing Database Connection](http://www.yiiframework.com/doc/guide/1.1/en/database.dao#establishing-database-connection "http://www.yiiframework.com/doc/guide/1.1/en/database.dao#establishing-database-connection")
[...]