好的,所以我正在做一个与上传文件和日期有关的项目。我的应用程序允许用户上传文件,他们可以看到自己上传的文档。他们可以根据需要删除它们。一旦他们认为上载的文件不错,就可以将其定稿,这意味着他们无法删除上载的文件。另外,单击“完成”按钮会将数据库中的状态更改为“已提交”,并放置时间戳。
到目前为止,我对这两个错误。我以某种方式在SQL中收到此错误:
更新leb2
。docs
AS Doc
SET Doc
。status
=“已提交”,Doc
。datesubmitted
= 2015-02-14 14:46:21在哪里Doc
。schoolId
= 15
错误:SQLSTATE [42000]:语法错误或访问冲突:1064您的SQL语法有错误;可能有错误。检查与您的MySQL服务器版本相对应的手册,以获取在'14:46:21 WHERE附近使用的正确语法Doc
。schoolId
=第1行15'
这些是我的代码:
public function finalize_init(){
$this->layout = 'school';
$id = $this->request->params['pass'][0];
$this->Doc->id = $id;
$this->Doc->updateAll(array(
'Doc.status' => '"Submitted"',
'Doc.datesubmitted' => date('Y-m-d H:i:s')
), array(
'Doc.schoolId'=>$id
)
);
$this->redirect(array('action'=>'documents_init'));
}
这是我的数据库表:
CREATE TABLE `docs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`schoolId` int(11) DEFAULT NULL,
`datesubmitted` datetime DEFAULT NULL,
`status` varchar(45) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
我不确定日期是什么错误。
我希望有人可以帮助我。谢谢!
编辑:
这些在我的日志里
Nr Query Error Affected Num. rows Took (ms)
1 SELECT `School`.`schoolId`, `School`.`usersId`, `School`.`name`, `School`.`email`, `School`.`term`, `School`.`address`, `School`.`existing_or_new`, `School`.`province`, `School`.`region`, `School`.`type`, `School`.`telephone`, `School`.`fax`, `School`.`dean`, `School`.`dean_email`, `School`.`llm`, `School`.`dean_mobile`, `School`.`president`, `School`.`educational_attainment`, `School`.`status` FROM `leb2`.`schools` AS `School` WHERE `usersId` = 49 LIMIT 1 1 1 1
2 SELECT COUNT(*) AS `count` FROM `leb2`.`docs` AS `Doc` WHERE `Doc`.`schoolId` = 17 AND `Doc`.`status` = 'draft' 1 1 1
3 INSERT INTO `leb2`.`docs` (`schoolId`, `status`) VALUES (17, 'draft') 1 1 30
4 SELECT `Doc`.`id`, `Doc`.`schoolId`, `Doc`.`datesubmitted`, `Doc`.`status`, `School`.`schoolId`, `School`.`usersId`, `School`.`name`, `School`.`email`, `School`.`term`, `School`.`address`, `School`.`existing_or_new`, `School`.`province`, `School`.`region`, `School`.`type`, `School`.`telephone`, `School`.`fax`, `School`.`dean`, `School`.`dean_email`, `School`.`llm`, `School`.`dean_mobile`, `School`.`president`, `School`.`educational_attainment`, `School`.`status` FROM `leb2`.`docs` AS `Doc` LEFT JOIN `leb2`.`schools` AS `School` ON (`Doc`.`schoolId` = `School`.`schoolId`) WHERE `Doc`.`schoolId` = 17 AND `Doc`.`status` = 'draft' LIMIT 1 1 1 1
5 SELECT `Doc`.`id`, `Doc`.`schoolId`, `Doc`.`datesubmitted`, `Doc`.`status`, `School`.`schoolId`, `School`.`usersId`, `School`.`name`, `School`.`email`, `School`.`term`, `School`.`address`, `School`.`existing_or_new`, `School`.`province`, `School`.`region`, `School`.`type`, `School`.`telephone`, `School`.`fax`, `School`.`dean`, `School`.`dean_email`, `School`.`llm`, `School`.`dean_mobile`, `School`.`president`, `School`.`educational_attainment`, `School`.`status` FROM `leb2`.`docs` AS `Doc` LEFT JOIN `leb2`.`schools` AS `School` ON (`Doc`.`schoolId` = `School`.`schoolId`) WHERE `Doc`.`schoolId` = 17 AND `Doc`.`status` = 'draft' LIMIT 1 1 1 1
6 SELECT `Upload`.`iduploads`, `Upload`.`iddocs`, `Upload`.`dest`, `Upload`.`type`, `Upload`.`description`, `Doc`.`id`, `Doc`.`schoolId`, `Doc`.`datesubmitted`, `Doc`.`status` FROM `leb2`.`uploads` AS `Upload` LEFT JOIN `leb2`.`docs` AS `Doc` ON (`Upload`.`iddocs` = `Doc`.`id`) WHERE `Upload`.`iddocs` = 20 0 0 1
Nr Query Error Affected Num. rows Took (ms)
1 UPDATE `leb2`.`docs` AS `Doc` SET `Doc`.`status` = "Submitted", `Doc`.`datesubmitted` = 2015 WHERE `Doc`.`schoolId` = 17 AND `Doc`.`status` = 'draft'
最终查询应如下所示:
UPDATE leb2.docs AS Doc SET Doc.status = "Submitted", Doc.datesubmitted = '2015-02-14 14:46:21' WHERE Doc.schoolId = 15;
查询中缺少的是日期提交值的qoute
$date = date('Y-m-d H:i:s');
$this->Doc->updateAll(array(
'Doc.status' => '"Submitted"',
'Doc.datesubmitted' => "'{$date}'"
), array(
'Doc.schoolId'=>$id
)
);
要实现查询,datesubmitted值应使用双qoute和单qoute“'{$ date}'”括起来
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句