【发布时间】:2015-07-06 15:39:31
【问题描述】:
我对 CodeIgniter 一无所知,希望得到一些帮助。在我工作的公司里,有一种租用礼服的预订系统,所以新娘们在去商店之前需要通过在线系统安排约会时间。该脚本是用 Codeigniter 编写的,错误是什么:一些记录在数据库中重复,我的意思是,id 保持不同,但是在管理员中,同一客户被显示为相同的日期时间 4、5 次,无论如何。这是在数据库中创建/插入计划的代码:
$agendamento = Agendamento::create(array(
'loja_id' => $this->input->post('loja_id'),
'usuario_id' => $this->input->post('usuario_id'),
'datahora' => $this->input->post('datahora'),
'loja' => $loja->nome,
'ultima_alteracao' => date('Y-m-d h:j:s'),
'status' => 'D-2'
));
以上数据来自一个ajax请求,这里:
$('#confirma_agendamento').on('click touchstart', function() {
$.ajax({
"dataType" : "text",
"type" : "POST",
"data" : {
"loja_id" : loja_selecionada,
"lista_espera" : lista_espera,
"usuario_id" : usuario_id,
"datahora" : data_selecionada + " " + hora_selecionada + ":00:00",
//"vestidos" : $("#vestidos").val()
},
"url" : base_url + 'ajax/lojas/agendar',
"success" : function (retorno) {
if (retorno == '1') {
window.location = SITE_URL + 'meus_agendamentos';
}
else {
showModal('<h1>Erro</h1><p>Houve algum problema com o seu agendamento. Por favor tente novamente em alguns instantes.</p>');
}
},
"error" : function() {
showModal('<h1>Erro</h1><p>Houve algum problema com o seu agendamento. Por favor tente novamente em alguns instantes.</p>');
}
});
});
所以,我的问题是:如何防止按日期时间重复记录,我的意思是,避免在 codeigniter 中同一日期时间出现 2 条记录?
【问题讨论】:
标签: php mysql codeigniter datetime