开发者

CakePHP cake bake giving error after selecting default

I just created a new project with CakePHP according to the main page you get after configuring everything i'm all in the green even database connection.

i run this command:

octavius@octavius-VirtualBox:/opt/lampp/htdocs/acltutorial/cake/console$ ./cake bake all

and this happens:

Welcome to CakePHP v1.3.7 Console
---------------------------------------------------------------
App : app
Path: /opt/lampp/htdocs/acltutorial/app
---------------------------------------------------------------
---------------------------------------------------------------
Bake All
---------------------------------------------------------------
Use Database Config: (default/test) 
[default] > 
PHP Fatal error:  Call to undefined function mysql_query() in /opt/lampp/htdocs/acltutorial/cake/libs/model/datasources/dbo/dbo_mysql.php on line 600

Fatal error: Call to undefined function mysql_query() in /opt/lampp/htdocs/acltutorial/cake/libs/model/datasources/dbo/dbo_mysql.php on line 600

I went into my php.ini file and added extension = 'mysql.so' an开发者_JAVA技巧d it still doesn't work. Anybody have any ideas?

PS: Doing table by table yields the same error

EDIT: After doing what dogmatic69 suggested i got these warnings:

PHP Warning:  mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /opt/lampp/htdocs/acltutorial/cake/libs/model/datasources/dbo/dbo_mysql.php on line 552

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /opt/lampp/htdocs/acltutorial/cake/libs/model/datasources/dbo/dbo_mysql.php on line 552
PHP Warning:  mysql_select_db() expects parameter 2 to be resource, boolean given in /opt/lampp/htdocs/acltutorial/cake/libs/model/datasources/dbo/dbo_mysql.php on line 558

    Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /opt/lampp/htdocs/acltutorial/cake/libs/model/datasources/dbo/dbo_mysql.php on line 558
    PHP Warning:  mysql_get_server_info() expects parameter 1 to be resource, boolean given in /opt/lampp/htdocs/acltutorial/cake/libs/model/datasources/dbo/dbo_mysql.php on line 566

    Warning: mysql_get_server_info() expects parameter 1 to be resource, boolean given in /opt/lampp/htdocs/acltutorial/cake/libs/model/datasources/dbo/dbo_mysql.php on line 566
    PHP Warning:  mysql_query() expects parameter 2 to be resource, boolean given in /opt/lampp/htdocs/acltutorial/cake/libs/model/datasources/dbo/dbo_mysql.php on line 600

    Warning: mysql_query() expects parameter 2 to be resource, boolean given in /opt/lampp/htdocs/acltutorial/cake/libs/model/datasources/dbo/dbo_mysql.php on line 600
    Your database does not have any tables.

Still doesn't work.


undo the changes you have made and then do something like this

sudo apt-get install php5-mysql

sudo service apache2 restart


It's not CakePHP error for sure. This means that mysql library is not loaded. When you added the extension did you restart the server? run phpinfo() in a file and see if the mysql is loaded.


This wasn't a cake error, apparently I had to specify the port in the database.php file like so:

'port' => '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock'

it couldn't connect to the database for baking, though it worked for the app itself, this fixed it.


This was running me crazy as well. I am on Ubuntu with XAMPP. Managed to fix it using 8vius' solution In the /app/config/database.php file

'port' => '/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜