码迷,mamicode.com
首页 > 数据库 > 详细

使用Phalcon开发工具碰到的数据库问题"Table 'XXX' doesn't exist in database when dumping meta-data for XXX"

时间:2015-05-12 01:30:31      阅读:1447      评论:0      收藏:0      [点我收藏+]

标签:

使用Phalcon开发工具,通过命令行生成程序框架

设置好config.php,在对数据库进行读取、保存数据的时候出现了问题“Table ‘XXX‘ doesn‘t exist in database when dumping meta-data for XXX”

技术分享

注意到上方还有一条语句“Array to string conversion”,找到对应services.php处的代码

1 $di->set(‘db‘, function () use ($config) {
2     return new DbAdapter($config->toArray());
3 });

再查看$config内容

$config = include __DIR__ . "/../app/config/config.php";

config.php内容

 1 <?php
 2 
 3 return new \Phalcon\Config(array(
 4     ‘database‘ => array(
 5         ‘adapter‘     => ‘Mysql‘,
 6         ‘host‘        => ‘localhost‘,
 7         ‘username‘    => ‘root‘,
 8         ‘password‘    => ‘‘,
 9         ‘dbname‘      => ‘eduhelper‘,
10         ‘charset‘     => ‘utf8‘,
11     ),
12     ‘application‘ => array(
13         ‘controllersDir‘ => __DIR__ . ‘/../../app/controllers/‘,
14         ‘modelsDir‘      => __DIR__ . ‘/../../app/models/‘,
15         ‘migrationsDir‘  => __DIR__ . ‘/../../app/migrations/‘,
16         ‘viewsDir‘       => __DIR__ . ‘/../../app/views/‘,
17         ‘pluginsDir‘     => __DIR__ . ‘/../../app/plugins/‘,
18         ‘libraryDir‘     => __DIR__ . ‘/../../app/library/‘,
19         ‘cacheDir‘       => __DIR__ . ‘/../../app/cache/‘,
20         ‘baseUri‘        => ‘/eduHelper/‘,
21     )
22 ));

经分析是数据库连接那块出了问题,可以看到$config中还有一个‘application‘,而我们所需要的显然只有‘database‘

应该将services.php处的代码改为

1 $di->set(‘db‘, function () use ($config) {
2     return new DbAdapter($config->database->toArray());
3 });

或者

$di->set(‘db‘, function () use ($config) {
    return new DbAdapter($config[‘database‘]->toArray());
});

 

使用Phalcon开发工具碰到的数据库问题"Table 'XXX' doesn't exist in database when dumping meta-data for XXX"

标签:

原文地址:http://www.cnblogs.com/cqq626/p/4496042.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!