我正在尝试开始使用 CakePHP 模式:app/Console/cake schema generate
我收到以下错误:
Welcome to CakePHP v2.3.0 Console
---------------------------------------------------------------
App : app
Path: /Applications/MAMP/htdocs/mysite/app/
---------------------------------------------------------------
Cake Schema Shell
---------------------------------------------------------------
Error: Database connection "Mysql" is missing, or could not be created.
这很令人困惑,因为该站点运行良好,因此 Config/database.php 中的数据库凭据是正确的。
更新: 因为我使用的是 MAMP,所以我在 $defualt 数组中的 Config/database.php 中添加了以下内容:
'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',
现在我没有得到原来的错误,而是一些新的错误:
Welcome to CakePHP v2.3.0 Console
---------------------------------------------------------------
App : app
Path: /Applications/MAMP/htdocs/mysite/app/
---------------------------------------------------------------
Cake Schema Shell
---------------------------------------------------------------
Generating Schema...
Notice Error: Schema generation error: invalid column type enum('normal','unlimited_time','admin','extra_time') for Attempt.type does not exist in DBO in [/Applications/MAMP/htdocs/mysite/lib/Cake/Model/CakeSchema.php, line 616]
Notice Error: Schema generation error: invalid column type enum('in_progress','complete','canceled') for Attempt.status does not exist in DBO in [/Applications/MAMP/htdocs/mysite/lib/Cake/Model/CakeSchema.php, line 616]
Notice Error: Schema generation error: invalid column type enum('MC','FI','CS','CQ','TF') for AttemptedQuestion.type does not exist in DBO in [/Applications/MAMP/htdocs/mysite/lib/Cake/Model/CakeSchema.php, line 616]
Notice Error: Schema generation error: invalid column type enum('1','2','3') for Category.category_order does not exist in DBO in [/Applications/MAMP/htdocs/mysite/lib/Cake/Model/CakeSchema.php, line 616]
Error: Table choices for model Choice was not found in datasource default.
#0 /Applications/MAMP/htdocs/mysite/lib/Cake/Model/Model.php(3217): Model->setSource('choices')
#1 /Applications/MAMP/htdocs/mysite/lib/Cake/Model/CakeSchema.php(260): Model->getDataSource()
#2 /Applications/MAMP/htdocs/mysite/lib/Cake/Console/Command/SchemaShell.php(149): CakeSchema->read(Array)
#3 /Applications/MAMP/htdocs/mysite/lib/Cake/Console/Shell.php(388): SchemaShell->generate()
#4 /Applications/MAMP/htdocs/mysite/lib/Cake/Console/ShellDispatcher.php(199): Shell->runCommand('generate', Array)
#5 /Applications/MAMP/htdocs/mysite/lib/Cake/Console/ShellDispatcher.php(67): ShellDispatcher->dispatch()
#6 /Applications/MAMP/htdocs/mysite/app/Console/cake.php(33): ShellDispatcher::run(Array)
#7 {main}
看起来 CakePHP 对 ENUM 字段感到害怕。