shinokada
(Okada Shin)
July 7, 2009, 11:48am
1
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.
Spyros
(Spyros)
July 7, 2009, 12:03pm
2
'db'=>array(
'connectionString'=>'mysql:host=YOUR_HOST;dbname=YOUR_DATABASE',
'username'=>'YOUR_USER',
'password'=>'YOUR_PASSWORD'
),
shinokada
(Okada Shin)
July 7, 2009, 1:17pm
3
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?
sclark
(Smclark89)
July 7, 2009, 1:34pm
4
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'
),
shinokada
(Okada Shin)
July 7, 2009, 2:15pm
5
It has , in mine.
I just did not type it in the previous post.
qiang
(Qiang Xue)
July 7, 2009, 7:18pm
6
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.
shinokada
(Okada Shin)
July 8, 2009, 6:32am
7
I checked it and it is correct.
Is there anyone using XAMPP for Yii?
If there is, tell me how you did it please?
Spyros
(Spyros)
July 8, 2009, 7:11am
8
I use xampp with no problems
Is the db configuration inside the components array?
kk1
(kk)
July 8, 2009, 7:29am
9
first of all you need to modify th php.ini file an uncomment the mysql statements
shinokada
(Okada Shin)
July 8, 2009, 8:21am
10
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?
kk1
(kk)
July 8, 2009, 9:08am
11
can you send me the php.ini file
Spyros
(Spyros)
July 8, 2009, 9:14am
12
The only command you need is
>>crud User
everything else will be created automatically
shinokada
(Okada Shin)
July 8, 2009, 9:45am
14
@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…
…
…
kk1
(kk)
July 8, 2009, 9:58am
15
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
shinokada
(Okada Shin)
July 8, 2009, 10:49am
16
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.
kk1
(kk)
July 8, 2009, 11:37am
17
you have not set primary key field for the user table
set it
shinokada
(Okada Shin)
July 8, 2009, 12:03pm
18
I has been set.
But it does not recognize it.
kk1
(kk)
July 8, 2009, 12:40pm
19
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
qiang
(Qiang Xue)
July 8, 2009, 2:19pm
20
What is the result of executing SQL: SHOW CREATE TABLE User