提问人:numuki sdf 提问时间:9/29/2019 最后编辑:suspectusnumuki sdf 更新时间:9/29/2019 访问量:282
如何使用PHP将下一个序列号与最后一个增量值更改?
How to alter next sequence number with last increment value using PHP?
问:
我想在每个循环之后更改下一个序列号。如何使用 PHP 获取最后一个递增的数字?
$incjobid = $job_Id++;//1,2,3,4,我需要用 5 更改下一个序列号。 一次插入 4 条记录,id 为 1,2,3,4,下一个序列号应该是 5.如何设置?
$this->db->select('NEXT VALUE FOR job_seq as jobid');
$queryjobid = $this->db->get();
foreach ($queryjobid->result_array() as $row) {
$job_Id = $row['jobid'];
}
if (is_array($this->input->post('getschedule'))) {
foreach($this->input->post('getschedule') as $value) {
//Auto generate JOB SCHEDULE HERE
$this->db->insert('job_schedule', array(
'jobschedule_id' => $jobschedule_id,
'Activity_area_id' => $Activity_area_id,
'Contract_id' => $this->input->post('getcontract_id'),
'job_freq_id' => $this->input->post('getcontractbranch_freq'),
'job_schedule_dates' => $value[0], //assume array form like your screenshot
'job_schedule_frequency' => $value[1],
'created_at' =>$created_Dt
));
//Auto generate JOB HERE
$incjobid = $job_Id++;
$this->db->insert('job', array(
'Job_id' => $incjobid,
'Job_no' => $incjobid,
'Contract_id' => $this->input->post('getcontract_id'),
'Job_Date' => $value[0],
'Start_time' => '08:30',
'Activity_Area_id' => $Activity_area_id,
'created_Dt' => $created_Dt,
'status' => 'open',
'sr_available' => '0'
//'end_time' => $this->input->post('getEnd_Time') ?: null,
//'team_id' => $this->input->post('getassignedtoJob'),
//'type_of_services_id' => $this->input->post('gettypeofserviceJob'),
//'type_of_visit_id' => $this->input->post('gettypeofvisitjob')
));
}
$insert_id = $this->db->insert_id();
//$this->db->ALTER('SEQUENCE job_seq RESTART WITH 547');
//$queryjobalter = $this->db->get();
//$queryjobalter->result();
}
答: 暂无答案
上一个:PHP 数组 - 将每个元素的数字(值)附加到字符串(键)
下一个:打印一系列字母
评论