Model Generator fails on creating table tbl_user

Hi!

I’ve installed Yii and decided to use mySQL with XAMPP.

Following the online guide, I go to the "Model Generator" with Gii and enter

  • tbl_user for Table name

  • User for Model Class

but when I go to press “preview” I got this error: “Table ‘tbl_user’ does not exist.”.

What can I do?

Thaaanks!

verify your config

Check your config.

Your config file is (should be) yourApp/protected/config/main.php.

[b]

[/b]You’ll find ‘db’ section in this file as follows:




'db'=>array(

 'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',

),


// uncomment the following to use a MySQL database

/*

'db'=>array(

 'connectionString' => 'mysql:host=localhost;dbname=testdrive',

 'emulatePrepare' => true,

 'username' => 'root',

 'password' => '',

 'charset' => 'utf8',

),

*/

If you use mysql database comment (or delete) the first example and uncomment the second, specifying the correct parameters. For example:




/*

'db'=>array(

 'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',

),

*/


// uncomment the following to use a MySQL database


'db'=>array(

 'connectionString' => 'mysql:host=localhost;dbname=yourdb',

 'emulatePrepare' => true,

 'username' => 'yourdbusername',

 'password' => 'yourdbpassword',

 'charset' => 'utf8',

),



Try again to create your Model with gii after changing this configuration.

Hi all,

this is my first time with yii and I’m using Xampp on a mac, following the online tutorial.

I have the same error of first post.

The error go away if I manually create the table on database…my config file seems ok.

So what’s wrong?

Is it necessry to create table by hand?

EDIT: Following the guide, entry index.php?r=user I get the error

Error 404

Unable to resolve the request "user".

:-[

Thank you for help

Nobody can help?

I don’t understand if the procedure will create the tables automatically or I have to do it manually on database.

Thank you

Hi!

I had the same issue here. Tried to create the table manually, and it seemed to be working but when I go to the user crud page no input form appears. I think gii SHOULD create the table automatically and donig it manually messes up something.

Anyway I find this online guide very disapponting. It skips a lot of details which are important for newbies in cteating their fitst app. There are lots of possible errors and glitches that should be explained further.

Now I’m stuck with this error, and having a very bad first impression of the whole yii frame work. :(

You have to create table on database manually. Then try to create model and all.