Jump to content
Larry Ullman's Book Forums

Yii Model Generator - Can Not Connect To Database

Recommended Posts

Barely installed Yii and already ran into trouble.

I'm running Windows 7 and use Wamp and MySQL for my database.

After installation, I went to the url http://localhost/myproject/index.php?r=gii and selected Model Generator.

I've edited both main.php and console.php in C:\wamp\www\myproject\protected\config folder to include the following:


            'connectionString' => 'mysql:host=localhost;dbname=myproject',
            'emulatePrepare' => true,
            'username' => 'myproject',
            'password' => 'thepassword',
            'charset' => 'utf8',


However, when trying to preview the model, the first field "Database Connection" gives me the following error:

"A valid database connection is required to run this generator."


I had the previous line in comments, and now tried changing into:

            'connectionString' => 'mysql',

Although it did not help.


I've tried googling around and people have had similar problems, but editing both of the files solved their problems. For some reason it won't work for me. Is 'localhost' all I need to point it to wamp and phpMyAdmin?


Can you help?

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...