i'm running yii on a mampstack environment. I have to specify where is located the sock file because it is not a standard location.
// uncomment the following to set up database
'db'=>array(
'connectionString'=>'mysql:host=localhost;dbname=testdrive;unix_socket=/Applications/mampstack-1.0/mysql/tmp/mysql.sock',
'username'=>'root',
'password'=>'password'
),
when i launch YiiRoot/framework/yiic shell WebRoot/testdrive/index.php and create the first model User yiic returns an exception :
'CDbException' with message 'CDbConnection failed to open the DB connection: could not find driver' in /Applications/mampstack-1.0/apache2/htdocs/dev/yii/framework/db/CDbConnection.php:228
all i can see is that i run shell then i type model user and it returns the error. i re-type model user and the class file is created correctly. it says
Warning: you do not have a 'db' database connection as required by Active Record.
generate user.php
The 'user' class has been successfully created in the following file:
the FIRST error it returns is '…could not find driver…' but i'm sure i have pdo mysql correctly installed because the test script you suggest before works.
that's probably the most important error.
anyway, if i don't close the shell and retype model user the class is created with the warning but in any of this cases i don't touch the main.php class while in the shell.
Hello ilzale…a little more info that could help you and other out:
A note on PHP and Mac OSX:
A version of PHP4 comes bundled on Mac OSX and is typically what is executed when you try the php command from the command line. You need to have the php command execute a version of PHP5.x or higher. Usually, you have already installed a version of PHP5.x or higher, but need to tell the php command to execute the newer version rather than the older one. There are certainly many ways to achieve this, but here is one:
at any terminal prompt, type in:
prompt>which php
this should tell you where the OS is looking for the php command
mine tells me /usr/bin/php
if I navigate to /usr/bin and issue an ls php I will see three files
php
php-config
phpize
These are all for the bundled version PHP4.x
rename these files to use a 4 in their names, to remember these are the executables for PHP4
mv php php4
mv php-config php-config4
mv phpize phpize4
Then, create sym links for each of these these to point to the PHP5.x or higher version you have installed. In my case these are located in /usr/local/apache/php/bin. So I would issue from the /usr/bin directory