我想在我的Mac上安装ZF1时使用Zend_Db_Expr
。这适用于生产,但在我的Mac上不起作用。我们的生产服务器运行MySQL 5.1,我的Mac运行5.6。有没有改变MySQL,它不允许Zend_Db_Expr
使用更高版本的MySQL?
我已尝试同时使用new Zend_DB_Expr('NULL')
以及new 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.'));
}
答案 0 :(得分: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.'));
}