为什么我会收到错误:当我将Zend Framework 2应用程序运行到远程服务器时,表不存在? [英] Why I receive error: table doesn't exist, when I run my Zend Framework 2 app to remote server?

查看:42
本文介绍了为什么我会收到错误:当我将Zend Framework 2应用程序运行到远程服务器时,表不存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个RESTful zend2应用程序,该应用程序可以在我的本地主机上正常工作.现在,我想将其部署在远程服务器上,并且遇到一些与Adabter相关的错误.我是zend Framework的新手,我不确定为什么会出现任何错误,因为我仔细检查了每件事都是正确的.我在网上搜索了此错误,但找不到任何与Zend2相关的有用答案.

I have created a RESTful zend2 app which is working fine on my localhost. Now I want to deploy it on the remote server and I get some errors related to the Adabter. I am new to zend framework and I am not sure why I get any errors, as I double checked every thing to be correct. I searched this error on the net, but I could not find any useful answer related to Zend2.

我导出了整个localhost数据库并将其导入到远程数据库,并将local.php和global.php中的所有数据库凭据更改为新主机中的新数据库.现在,当我想访问应用程序的数据库部分时,在模块中(例如myApp/user,它应该以json格式提供db数据库中的用户列表),它给了我以下错误(对不起)如果我给出了很多错误消息,我只是想详细说明我的问题):

I exported the whole localhost database and imported it to the remote database and changed all the database credentials in local.php and global.php to the new database in the new host. Now when I want to access the database part of the app, in the module(Like myApp/user which it supposed to give me the list of the users in the db in json format), It gives me the following errors (I am sorry if I am giving to much error messages. I just want my question to be detailed):

文件:

/var/www/myApp/vendor/zendframework/zend-db/src/Adapter/Driver/Pdo/Statement.php:244

消息:

Statement could not be executed: 42S02 - 1146 - Table 'myAppDatabase.User' doesn't exist

堆栈跟踪:

#0 /var/www/myApp/vendor/zendframework/zend-db/src/TableGateway/AbstractTableGateway.php(238): Zend\Db\Adapter\Driver\Pdo\Statement->execute()
#1 /var/www/myApp/vendor/zendframework/zend-db/src/TableGateway/AbstractTableGateway.php(208): Zend\Db\TableGateway\AbstractTableGateway->executeSelect(Object(Zend\Db\Sql\Select))
#2 /var/www/myApp/vendor/zendframework/zend-db/src/TableGateway/AbstractTableGateway.php(195): Zend\Db\TableGateway\AbstractTableGateway->selectWith(Object(Zend\Db\Sql\Select))
#3 /var/www/myApp/module/User/src/User/Model/UserTable.php(17): Zend\Db\TableGateway\AbstractTableGateway->select()
#4 /var/www/myApp/module/User/src/User/Controller/UserController.php(40): User\Model\UserTable->fetchAll()
#5 /var/www/myApp/vendor/zendframework/zend-mvc/src/Controller/AbstractRestfulController.php(370): User\Controller\UserController->getList()
#6 [internal function]: Zend\Mvc\Controller\AbstractRestfulController->onDispatch(Object(Zend\Mvc\MvcEvent))
#7 /var/www/myApp/vendor/zendframework/zend-eventmanager/src/EventManager.php(444): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#8 /var/www/myApp/vendor/zendframework/zend-eventmanager/src/EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#9 /var/www/myApp/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php(118): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#10 /var/www/myApp/vendor/zendframework/zend-mvc/src/Controller/AbstractRestfulController.php(300): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#11 /var/www/myApp/vendor/zendframework/zend-mvc/src/DispatchListener.php(93): Zend\Mvc\Controller\AbstractRestfulController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#12 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#13 /var/www/myApp/vendor/zendframework/zend-eventmanager/src/EventManager.php(444): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#14 /var/www/myApp/vendor/zendframework/zend-eventmanager/src/EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#15 /var/www/myApp/vendor/zendframework/zend-mvc/src/Application.php(314): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#16 /var/www/myApp/public/index.php(21): Zend\Mvc\Application->run()
#17 {main}

以前的例外: PDO例外:

Previous exceptions: PDO exception:

文件:

/var/www/myApp/vendor/zendframework/zend-db/src/Adapter/Driver/Pdo/Statement.php:239

消息:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'myAppDatabase.User' doesn't exist

堆栈跟踪:

#0 /var/www/myApp/vendor/zendframework/zend-db/src/Adapter/Driver/Pdo/Statement.php(239): PDOStatement->execute()
#1 /var/www/myApp/vendor/zendframework/zend-db/src/TableGateway/AbstractTableGateway.php(238): Zend\Db\Adapter\Driver\Pdo\Statement->execute()
#2 /var/www/myApp/vendor/zendframework/zend-db/src/TableGateway/AbstractTableGateway.php(208): Zend\Db\TableGateway\AbstractTableGateway->executeSelect(Object(Zend\Db\Sql\Select))
#3 /var/www/myApp/vendor/zendframework/zend-db/src/TableGateway/AbstractTableGateway.php(195): Zend\Db\TableGateway\AbstractTableGateway->selectWith(Object(Zend\Db\Sql\Select))
#4 /var/www/myApp/module/User/src/User/Model/UserTable.php(17): Zend\Db\TableGateway\AbstractTableGateway->select()
#5 /var/www/myApp/module/User/src/User/Controller/UserController.php(40): User\Model\UserTable->fetchAll()
#6 /var/www/myApp/vendor/zendframework/zend-mvc/src/Controller/AbstractRestfulController.php(370): User\Controller\UserController->getList()
#7 [internal function]: Zend\Mvc\Controller\AbstractRestfulController->onDispatch(Object(Zend\Mvc\MvcEvent))
#8 /var/www/myApp/vendor/zendframework/zend-eventmanager/src/EventManager.php(444): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#9 /var/www/myApp/vendor/zendframework/zend-eventmanager/src/EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#10 /var/www/myApp/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php(118): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#11 /var/www/myApp/vendor/zendframework/zend-mvc/src/Controller/AbstractRestfulController.php(300): Zend\Mvc\Controller\AbstractController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#12 /var/www/myApp/vendor/zendframework/zend-mvc/src/DispatchListener.php(93): Zend\Mvc\Controller\AbstractRestfulController->dispatch(Object(Zend\Http\PhpEnvironment\Request), Object(Zend\Http\PhpEnvironment\Response))
#13 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))
#14 /var/www/myApp/vendor/zendframework/zend-eventmanager/src/EventManager.php(444): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#15 /var/www/myApp/vendor/zendframework/zend-eventmanager/src/EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#16 /var/www/myApp/vendor/zendframework/zend-mvc/src/Application.php(314): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))
#17 /var/www/myApp/public/index.php(21): Zend\Mvc\Application->run()
#18 {main}

对于解决此错误的任何帮助,我们将不胜感激.

I will appreciate any help for resolving this error.

如果我在这里缺少一些信息,请原谅我,如果您需要更多详细信息,请告诉我.

Forgive me if I am missing some information here and let me know if you need any more details.

先谢谢了.

推荐答案

您真的确定所有配置都正确吗? :)

如果是,则可能是您已更改为对大小写敏感的系统不区分大小写的系统.也许您可以进入数据库(使用phpmyadmin或类似方法检查表是否存在且名称对应).或尝试将所有表重命名为小写字母(小写).

If yes, then it could be that you changed to a system that is not case sensitive to a case sensitive system. Maybe you can go in your database (with phpmyadmin or similar to check if the table exist and the name corresponds). Or try to rename all tables to small characters (lowercase).

为避免在移动/复制/迁移时出现问题,建议仅使用小写名称.因此,没有像您这样的骆驼装箱,而是使用下划线.

To avoid problems while moving/copying/migrating it is anyway advisable to only use lowercase names for tables and columns. So no camel-casing like you did but rather use underscores.

因此,例如,尝试将名称更改为my_app_database(表)和user(列),然后测试其是否正常工作.

So try to for example to change the names to my_app_database (table) and user (column) and test if it works then.

这篇关于为什么我会收到错误:当我将Zend Framework 2应用程序运行到远程服务器时,表不存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆