Skip to content

Instantly share code, notes, and snippets.

@zgramming
Last active September 12, 2019 12:24
Show Gist options
  • Save zgramming/7dd924a2debf87e9d6d459bd0aa4a8bb to your computer and use it in GitHub Desktop.
Save zgramming/7dd924a2debf87e9d6d459bd0aa4a8bb to your computer and use it in GitHub Desktop.
CONTROLLER
public function updateStatus()
{
$id_berita = $this->input->post('id_berita');
$object = ["status_berita" => "true"];
$updateStatus = $this->berita->updateStatusBerita($object, $id_berita);
if ($updateStatus) {
echo "berhasil";
} else {
echo "gagal";
}
}
-------------------------------------------------------------------------------------------------------------------------------------
MODEL
public function updateStatusBerita($object, $id_berita)
{
$this->db->where('id_berita', $id_berita);
return $this->db->update('tb_berita', $object);
}
-------------------------------------------------------------------------------------------------------------------------------------
TRIGGER<<<
CREATE TRIGGER updateHeadlineBerita AFTER UPDATE ON tb_berita
FOR EACH ROW BEGIN UPDATE tb_berita SET status_berita='false'
WHERE status_berita="true" AND status_berita !=id_berita
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment