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

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

时间:2021-07-01 10:21:17 帮助过:4人阅读

$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"

标签:

人气教程排行