选择默认值后,CakePHP蛋糕烘焙给出错误

时间:2011-03-17 21:53:04

标签: cakephp php

我刚刚使用CakePHP创建了一个新项目,根据您在配置绿色甚至数据库连接的所有内容后获得的主页面。

我运行此命令:

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

发生了这种情况:

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

我进入了我的php.ini文件并添加了extension ='mysql.so',但它仍然无效。有人有什么想法吗?

PS:按表执行表会产生相同的错误

编辑:做了dogmatic69之后建议我收到这些警告:

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.

仍然无效。

4 个答案:

答案 0 :(得分:4)

撤消您所做的更改,然后执行类似的操作

sudo apt-get install php5-mysql

sudo service apache2 restart

答案 1 :(得分:0)

肯定不是CakePHP错误。这意味着没有加载mysql库。添加扩展名后,您是否重新启动了服务器?在文件中运行phpinfo()并查看是否加载了mysql。

答案 2 :(得分:0)

这不是蛋糕错误,显然我必须在database.php文件中指定端口,如下所示:

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

它无法连接到数据库进行烘焙,虽然它适用于应用程序本身,但这已经修复了它。

答案 3 :(得分:0)

这让我疯了。我和XAMPP在Ubuntu上。管理使用8vius解决方案修复它 在/app/config/database.php文件中

  

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