Ami Posted February 19, 2013 Share Posted February 19, 2013 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: 'db'=>array( '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: 'db'=>array( '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 comment Share on other sites More sharing options...
Ami Posted February 20, 2013 Author Share Posted February 20, 2013 The joy of answering my own thread! I had written the database's name in the "Database Connection" field. It was not necessary, however, I should have just let it be the default value 'db'. Glad it worked now! Link to comment Share on other sites More sharing options...
Larry Posted February 20, 2013 Share Posted February 20, 2013 Ah, that makes sense. Kudos for figuring it out and thanks for sharing. Link to comment Share on other sites More sharing options...
Recommended Posts