gpt4 book ai didi

php - 如何在 2 表中更新? (t_judul 和 mahasiswa 中的 id_status)

转载 作者:行者123 更新时间:2023-11-30 21:29:09 26 4
gpt4 key购买 nike

我尝试在 t_judul 和 mahasiswa 上更新 id_status 并将我的数据保存在 t_jadwal 上,所以我尝试了这段代码

Sql 在t_judul 上成功保存数据但是 sql2 和 sql3 无法将表 t_judul 和 mahasiswa 中的 id_status 更新为 54

我的模型

public function simpanjadwal($post,$id_judul){
$id_judul = $this->db->escape($post['id_judul']);
$id_status = $this->db->escape($post['id_status']);
$judul = $this->db->escape($post['judul']);
$topik = $this->db->escape($post['topik']);
$nim = $this->db->escape($post['nim']);
$nama_awal = $this->db->escape($post['nama_awal']);
$nama_akhir = $this->db->escape($post['nama_akhir']);
$pbb1 = $this->db->escape($post['pbb1']);
$pbb2 = $this->db->escape($post['pbb2']);
$pgj1 = $this->db->escape($post['pgj1']);
$pgj2 = $this->db->escape($post['pgj2']);
$waktuujian = $this->db->escape($post['waktuujian']);
$tempatujian = $this->db->escape($post['tempatujian']);

$sql = $this->db->query("INSERT INTO t_jadwal (
id_judul,
id_status,
judul,
topik,
nim,
nama_awal,
nama_akhir,
pbb1,
pbb2,
pgj1,
pgj2,
waktuujian,
tempatujian
)
VALUES
(
$id_judul,
$id_status,
$judul,
$topik,
$nim,
$nama_awal,
$nama_akhir,
$pbb1,
$pbb2,
$pgj1,
$pgj2,
$waktuujian,
$tempatujian
)");
$sql2 = $this->db->query("UPDATE mahasiswa, t_judul SET mahasiswa.id_status = 54 WHERE t_judul.nim = mahasiswa.nim AND t_judul.id_judul = ".intval($id_judul));
$sql3 = $this->db->query("UPDATE t_judul,mahasiswa SET t_judul.id_status = 54 WHERE t_judul.nim = mahasiswa.nim AND t_judul.id_judul = ".intval($id_judul));

return TRUE;
}

我的 Controller

public function inputjadwalseminar($id_judul){
$this->load->model("m_pkip");

$data['list_judulseminar'] = $this->m_pkip->selectjudul($id_judul);
$data['list_dosen'] = $this->m_pkip->load_dosen();
if(isset($_POST['btnSimpanJadwal'])){
$this->m_pkip->simpanjadwal($_POST, $id_judul);
redirect("pkip");
}
$data['default'] = $this->m_pkip->get_default($id_judul);
$this->load->view("pkip/v_inputjadwalseminar",$data);
}

sql2 和 sql3 查询无法更新 t_judul 和 mahasiswa 中的 id_status 但数据成功保存在 t_jadwal 上

我尝试转储 sql2 和 sql3,结果是 bool(true) bool(true)我试图转储 id_judul,它说 string(4)"72"*note 72 是 id_judul

最佳答案

解决了我把我的代码改成

$sql2  = $this->db->query("UPDATE mahasiswa, t_judul SET mahasiswa.id_status = 54 WHERE t_judul.nim = mahasiswa.nim AND t_judul.id_judul = $id_judul"); 

$sql3 = $this->db->query("UPDATE t_judul,mahasiswa SET t_judul.id_status = 54 WHERE t_judul.nim = mahasiswa.nim AND t_judul.id_judul = $id_judul");

关于php - 如何在 2 表中更新? (t_judul 和 mahasiswa 中的 id_status),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57237914/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com