Last active
September 12, 2019 12:24
-
-
Save zgramming/7dd924a2debf87e9d6d459bd0aa4a8bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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