好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

使用Phalcon开发工具碰到的数据库问题"Table 'XXX' doe

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

标签:

查看更多关于使用Phalcon开发工具碰到的数据库问题"Table 'XXX' doe的详细内容...

  阅读:32次