0

我正在尝试Zend_Db_Expr在我的 Mac 上安装 ZF1。这适用于生产,但不适用于我的 Mac。我们的生产服务器运行 MySQL 5.1,我的 Mac 运行 5.6。MySQL 是否发生了一些变化,它不允许Zend_Db_Expr与更高版本的 MySQL 一起使用?

我已经尝试过使用 bothnew Zend_DB_Expr('NULL')和 bothnew Zend_Db_Expr('NOW')并且new Zend_Db_Expr('NOW()')两者都不起作用。(我相信后者是正确的。有没有人知道为什么会发生这种情况。

我不知道是因为我在 Mac 上还是只是 MySQL 的变化。我会很感激任何帮助。我得到的错误是Incorrect datetime value: 'NOW()' for column 'date_closed'但也Incorrect datetime value: 'NOW' for column 'date_closed'

$arrData['internal_review_date']        = $this->getRequest()->getPost('internal_review_date','0000-00-00 00:00:00');
            if ($arrData['internal_review_date'] != '0000-00-00 00:00:00') {
                $arrData['internal_review_date'] = date('Y-m-d', strtotime($arrData['internal_review_date']));
            }
            $arrData['desired_launch_date']        = $this->getRequest()->getPost('desired_launch_date','0000-00-00 00:00:00');
            if ($arrData['desired_launch_date'] != '0000-00-00 00:00:00') {
                $arrData['desired_launch_date'] = date('Y-m-d', strtotime($arrData['desired_launch_date']));
            }
            $arrData['submitted_by']         = trim($this->getRequest()->getPost('submitted_by'));
            $arrData['approved_by']          = trim($this->getRequest()->getPost('approved_by'));
            $arrData['approval_date']        = $this->getRequest()->getPost('approval_date','0000-00-00 00:00:00');
            if ($arrData['approval_date'] != '0000-00-00 00:00:00') {
                $arrData['approval_date'] = date('Y-m-d', strtotime($arrData['approval_date']));
            }
            $arrData['myriad_notes']        = $this->getRequest()->getPost('myriad_notes');
            $arrData['approved_by']          = trim($this->getRequest()->getPost('approved_by'));
            $arrData['request']              = trim($this->getRequest()->getPost('request'));
            $arrData['objective']            = trim($this->getRequest()->getPost('objective'));
            $arrData['additional_info']      = trim($this->getRequest()->getPost('additional_info'));
            $arrData['study_club']           = (int) $this->getRequest()->getPost('study_club');
            $arrData['digital_campus']       = (int) $this->getRequest()->getPost('digital_campus');
            $arrData['case_assistant']       = (int) $this->getRequest()->getPost('case_assistant');
            $arrData['faculty_club']         = (int) $this->getRequest()->getPost('faculty_club');
            $arrData['spear_review']         = (int) $this->getRequest()->getPost('spear_review');
            $arrData['spear_talk']           = (int) $this->getRequest()->getPost('spear_talk');
            $arrData['admin']                = (int) $this->getRequest()->getPost('admin');
            $arrData['other']                = (int) $this->getRequest()->getPost('other');
            $arrData['request_status']       = $this->getRequest()->getPost('request_status', 'Active');
            if ($arrData['request_status'] == 'Completed') {
                $arrData['date_closed'] = new Zend_Db_Expr('NOW');
            } else {
                $arrData['date_closed'] = '0000-00-00 00:00:00';
            }


....
 $objWebsite = new Website_Requests();
if ($intId == 0) {
                    $arrData['date_created'] = new Zend_Db_Expr('NOW()');
                    $intId = $objWebsite->insert($arrData);
                    $this->_helper->FlashMessenger(array('success' => 'The Website Request Form has been submitted successfully.'));
                } else {
                    $arrData['date_updated'] = new Zend_Db_Expr('NOW()');
                    $strWhere = $objWebsite->getAdapter()->quoteInto('id = ?', $intId);
                    $objWebsite->update($arrData, $strWhere);
                    $this->_helper->FlashMessenger(array('success' => 'The Website Request Form has been updated successfully.'));
                }
4

1 回答 1

0

有趣的。我要做的就是将有问题的部分移到更新调用中。像这样:

if ($intId == 0) {
                    $arrData['date_created'] = new Zend_Db_Expr('NOW()');
                    $intId = $objWebsite->insert($arrData);
                    $this->_helper->FlashMessenger(array('success' => 'The Website Request Form has been submitted successfully.'));
                } else {
                    $arrData['date_updated'] = new Zend_Db_Expr('NOW()');
                    if ($arrData['request_status'] == 'Completed') {
                        $arrData['date_closed'] = new Zend_Db_Expr('NOW()');
                    } else {
                        $arrData['date_closed'] = '0000-00-00 00:00:00';
                    }
                    $strWhere = $objWebsite->getAdapter()->quoteInto('id = ?', $intId);
                    $objWebsite->update($arrData, $strWhere);
                    $this->_helper->FlashMessenger(array('success' => 'The Website Request Form has been updated successfully.'));
                }
于 2013-08-27T18:44:08.600 回答