Yii Framework Forum: CDbConnection.connectionString cannot be empty. - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

CDbConnection.connectionString cannot be empty. Rate Topic: -----

#1 User is offline   Dennis 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 12-October 09

Posted 01 November 2009 - 05:49 PM

Trying to create a new app using mysql, used sqlite for the demo and had no problems. Changed main.php to:


'db'=>array(
'class'=>'CDbConnection',
'connectionString'=>'mysql:host=localhost;dbname=Eitilte',
'username'=>'eitilteuser',
'password'=>'4Ks%acG1Fu',
'emulatePrepare'=>true,
),

when I invoke the model command in the shell I get:

exception 'CDbException' with message 'CDbConnection.connectionString cannot be empty.' in /Users/dennisoconnor/yii-1.0.9.r1396/framework/db/CDbConnection.php:238

Using a terminal window I can connect to mysql and see the tables within the Eitilte database.

I can't figure out why it thinks connectionString is empty.

I'm working on a MacBook Pro using Snow Leopard and it native PHP 5.3.0 environment

phpinfo(); shows:

PDO
PDO support enabled
PDO drivers mysql, sqlite, sqlite2

pdo_mysql
PDO Driver for MySQL enabled
Client API version mysqlnd 5.0.5-dev - 081106 - $Revision: 1.3.2.27 $
Persistent cache enabled
put_hits 0
put_misses 0
get_hits 0
get_misses 0
size 2000
free_items 2000
references 2

Directive Local Value Master Value
pdo_mysql.cache_size 2000 2000
pdo_mysql.default_socket /var/mysql/mysql.sock /var/mysql/mysql.sock

any help would be greatly appreciated.

Dennis
0

#2 User is offline   Kaerigan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 05-December 08
  • Location:Sweden

Posted 01 November 2009 - 06:35 PM

Quote

'db'=>array(
'class'=>'CDbConnection',
'connectionString'=>'mysql:host=localhost;dbname=Eitilte',
'username'=>'eitilteuser',
'password'=>'4Ks%acG1Fu',
'emulatePrepare'=>true,
),


Is that the entire contents of main.php? If that is the case, you have to put the 'db' key under the 'components' array:

'components' => array(
'db'=>array(
'class'=>'CDbConnection',
'connectionString'=>'mysql:host=localhost;dbname=Eitilte',
'username'=>'eitilteuser',
'password'=>'4Ks%acG1Fu',
'emulatePrepare'=>true,
),
)

Yesterday is history,
tomorrow is a mystery,
today is a gift - that's why they call it present.
0

#3 User is offline   Dennis 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 12-October 09

Posted 01 November 2009 - 06:54 PM

View PostKaerigan, on 01 November 2009 - 06:35 PM, said:

Is that the entire contents of main.php? If that is the case, you have to put the 'db' key under the 'components' array:

'components' => array(
'db'=>array(
'class'=>'CDbConnection',
'connectionString'=>'mysql:host=localhost;dbname=Eitilte',
'username'=>'eitilteuser',
'password'=>'4Ks%acG1Fu',
'emulatePrepare'=>true,
),
)


0

#4 User is offline   Dennis 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 12-October 09

Posted 01 November 2009 - 06:56 PM

I just showed the db array. It is part of the components array.

Thanks for the response!
0

#5 User is offline   Kaerigan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 22
  • Joined: 05-December 08
  • Location:Sweden

Posted 01 November 2009 - 07:34 PM

No problem, but wow. That's really weird.

Uh... are you sure you're editing the correct file? xD I actually did that the other day (editing the wrong file, I mean). Anyway, I don't think there are any problems with your MySQL installation. If there were, I'm pretty sure you'd get other kinds of errors. I'd just try to figure out if there's something wrong with the application structure or something like that.

I'm sorry that I couldn't help you.
Yesterday is history,
tomorrow is a mystery,
today is a gift - that's why they call it present.
0

#6 User is offline   Dennis 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 12-October 09

Posted 02 November 2009 - 12:02 AM

I'm feeling pretty foolish. I'm new to Netbeans and Subversion. I was editing a file in Netbeans and running the shell against a different directory. I very sorry if I wasted yours or anyone's time chasing a non-problem. Every thing is working just fine now that I'm working against the right set of files.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users