duangang4940 2012-11-25 23:07
浏览 30
已采纳

Zend_db只在我的主模块中出错,并且只有当我使用'woningen'作为表名时

This is the code I use to update/insert data in my database.

public function saveItem($post, $table)
    {
        unset($post['submit']);
        $this->_table = new Zend_Db_Table($table); exit;

        if (isset($post['id'])) {
            $where = $this->_table->getAdapter()->quoteInto('id = ?', $post['id']);
            $this->_table->update($post, $where);
            return $post['id'];
        } else {
            return $this->_table->insert($post);
        }
    }

For some reason

$this->_table = new Zend_Db_Table($table);

Gives me a error but only when $table = 'woningen' and only in my main module.

Here is the error:

APPLICATION ERROR
EXCEPTION INFORMATION:
Message: Argument must be of type Zend_Db_Adapter_Abstract, or a Registry key where a Zend_Db_Adapter_Abstract object is stored
STACK TRACE:
#0 D:\xampp\htdocs\makeltrent.website\library\Zend\Db\Table\Abstract.php(581): Zend_Db_Table_Abstract::_setupAdapter('woningen')
#1 D:\xampp\htdocs\makeltrent.website\library\Zend\Db\Table\Abstract.php(283): Zend_Db_Table_Abstract->_setAdapter('woningen')
#2 D:\xampp\htdocs\makeltrent.website\library\Zend\Db\Table\Abstract.php(265): Zend_Db_Table_Abstract->setOptions(Array)
#3 D:\xampp\htdocs\makeltrent.website\library\Zend\Db\Table.php(77): Zend_Db_Table_Abstract->__construct(Array)
#4 D:\xampp\htdocs\makeltrent.website\application\models\Inlog.php(109): Zend_Db_Table->__construct('woningen')
#5 D:\xampp\htdocs\makeltrent.website\application\modules\default\controllers\WoningmandjeController.php(157): Application_Model_Inlog->saveItem(Array, 'woningen')
#6 D:\xampp\htdocs\makeltrent.website\library\Zend\Controller\Action.php(516): WoningmandjeController->sendAction()
#7 D:\xampp\htdocs\makeltrent.website\library\Zend\Controller\Dispatcher\Standard.php(295): Zend_Controller_Action->dispatch('sendAction')
#8 D:\xampp\htdocs\makeltrent.website\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#9 D:\xampp\htdocs\makeltrent.website\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#10 D:\xampp\htdocs\makeltrent.website\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#11 D:\xampp\htdocs\makeltrent.website\public\index.php(26): Zend_Application->run()
#12 {main} 

  • 写回答

2条回答 默认 最新

  • dscizpq790832708 2012-11-26 13:53
    关注

    My first thought, as explained by the error message, is that you have a Zend_Registry key by that name, but not an object of something like a Zend_Db_Adapter_Pdo_Mysql, which is what it's expecting. A random string would not fail for that reason, since it would end up returning false, or null - which simply returns out of the _setupAdapter function without doing anything.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊