У меня проблема в панели php, когда я пытаюсь добавить дату доставки продукта, он также изменяется у всех других пользователей, я не знаю, если это ошибка в базе данных или php, я оставлю ниже некоторые ссылкиextruturas.
Файл: Time_model.php
<?php
class Time_model extends CI_Model{
function get_time_slot(){
$q = $this->db->query("Select * from time_slots limit 1");
return $q->row();
}
function get_closing_date($date,$store_id){
$q = $this->db->query("Select * from closing_hours WHERE store_id=".$store_id." AND date >= '".date("Y-m-d",strtotime($date))."'");
return $q->result();
}
function get_closing_hours($date){
$q = $this->db->query("Select * from closing_hours where date = '".date("Y-m-d",strtotime($date))."'");
return $q->result();
}
}
?>
Файл: Admin.php
public function time_slot(){
if(_is_user_login($this)){
$this->load->model("time_model");
$timeslot = $this->time_model->get_time_slot();
$this->load->library('form_validation');
$this->form_validation->set_rules('opening_time', 'Opening Hour', 'trim|required');
$this->form_validation->set_rules('closing_time', 'Closing Hour', 'trim|required');
if ($this->form_validation->run() == FALSE)
{
if($this->form_validation->error_string()!="")
$this->session->set_flashdata("message", '<div class="alert alert-warning alert-dismissible" role="alert">
<i class="fa fa-warning"></i>
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<strong>Warning!</strong> '.$this->form_validation->error_string().'
</div>');
}
else
{
if(empty($timeslot)){
$q = $this->db->query("Insert into time_slots(opening_time,closing_time,time_slot) values('".date("H:i:s",strtotime($this->input->post('opening_time')))."','".date("H:i:s",strtotime($this->input->post('closing_time')))."','".$this->input->post('interval')."')");
}else{
$q = $this->db->query("Update time_slots set opening_time = '".date("H:i:s",strtotime($this->input->post('opening_time')))."' ,closing_time = '".date("H:i:s",strtotime($this->input->post('closing_time')))."',time_slot = '".$this->input->post('interval')."' ");
}
}
$timeslot = $this->time_model->get_time_slot();
$this->load->view("admin/timeslot/editm",array("schedule"=>$timeslot));
}
else
{
redirect("admin");
Структура таблицы:
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
-- --------------------------------------------------------
--
-- Table structure for table `time_slots`
--
CREATE TABLE `time_slots` (
`opening_time` time NOT NULL,
`closing_time` time NOT NULL,
`time_slot` int(11) NOT NULL,
`store_id` varchar(500) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `time_slots`
--
INSERT INTO `time_slots` (`opening_time`, `closing_time`, `time_slot`, `store_id`) VALUES
('05:02:00', '12:00:00', 60, '319'),
('05:02:00', '12:00:00', 60, '320'),
('05:02:00', '12:00:00', 60, '321');
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Пожалуйста, помогите мне, я пытаюсь решить эту проблему в течение нескольких дней, но у меня мало знаний.