Mysql Database

I am following the document.

In the document "http://www.yiiframework.com/doc/guide/quickstart.first-app", under Connecting to Database, it says,

return array(

    …

    'components'=>array(

        …

        'db'=>array(

            'connectionString'=>'sqlite:protected/data/source.db',

        ),

    ),

    …

);

I am using XAMPP. I can make db in phpmyAdmin, but what I need to write for 'sqlite:protected/data/source.db'?

Thanks in advance.



'db'=>array(


    'connectionString'=>'mysql:host=YOUR_HOST;dbname=YOUR_DATABASE',


    'username'=>'YOUR_USER',


    'password'=>'YOUR_PASSWORD'


   ),


Ok, I tried the above code.

'db'=>array( 'connectionString'=>'mysql:host=localhost;dbname=myDBName', 'username'=> 'root', 'password'=> 'mypass' )

Then using cmd,

cd WebRoot/testdrive

protected/yiic shell

Yii Interactive Tool v1.0

Please type 'help' for help. Type 'exit' to quit.

>> model User

  generate User.php

But I keep getting the following error.

exception 'CDbException' with message 'CDbconnection.connectionSting cannot be empty.' in c:\xampp\htdocs\yii\framework\db\CDbConnection.php:238

Stck trace:

What do I need to do?

I'm not sure if this is the problem, or if you just didn't paste it in with the code, but the last parentheses needs a comma after it. For example, here's mine:

'db'=>array(


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


    		'username' => 'root',


    		'password' => 'password'


		),

It has , in mine.

I just did not type it in the previous post.

It seems you configuration is not being used. Check your entry script index.php about the configuration file you are using, and make sure you are modifying the right configuration file.

I checked it and it is correct.

Is there anyone using XAMPP for Yii?

If there is, tell me how you did it please?

I use xampp with no problems

Is the db configuration inside the components array?

first of all you need to modify th php.ini file an uncomment the mysql statements

Silly me. I did not take out comment /*  */.

I have a next question.

The command in the document should be like this??

>> crud User;

  generate UserController.php;

  generate create.php;

  mkdir D:/wwwroot/testdrive/protected/views/user;

  generate update.php;

  generate list.php;

  generate show.php;

I am using windows cmd. I think semi-colons are needed for this, right?

can you send me the php.ini file

The only command you need is

>>crud User

everything else will be created automatically

write crud model

in cmd

@kk; this forum does not allow to send more than 2000 characters.

@Spyros; I get the following error now.

exception 'CDbException' with message 'The table "generate" for active record class "User" cannot b e found in the databasee.' in c:\xampp\htdocs\yii\framework\db\ar\CActiveRecord.php:2154

Stack trace:

#0 c:`\xampp\htdocs…

did you see the blog demo??

in cmd you should be in the path of php folder

D:\xampp\php>d:\yii\framework\yiic shell d:\xampp\htdocs\wwwroot\cart11\index.php

after that it will come

Yii Interactive Tool v1.0 (based on Yii v1.0.6)

Please type 'help' for help. Type 'exit' to quit.

>>

now write

>>model User

some thing will display

then write

>>crud User

  generate UserController.php

      mkdir D:/xampp/htdocs/wwwroot/cart11/protected/views/User

  generate create.php

  generate update.php

  generate list.php

  generate show.php

  generate admin.php

  generate _form.php

Crud 'user' has been successfully created. You may access it via:

http://hostname/path…ndex.php?r=user

try it

I get upto here is alright.

WebRoot\testdrive

protected\yiic shell

Yii Interactive Tool v1.0

Please type 'help' for help. Type 'exit' to quit.

>> model User

 

This generate user.php, so it is working. then problem is the next.

>> crud User

I get this error message this time.

Error: Table "generate" does not have a primary key.

Oh my.

you have not set primary key field for the user table

set it

I has been set.  :(

But it does not recognize it.

i think primary means a seperate key with auto increment facility

try it create a new id in the user table and make it primary + autoincrement

remove the primary key property of the already set key

What is the result of executing SQL: SHOW CREATE TABLE User