-6
我的模型廣東話插入到數據庫笨
<?php
class Keluhan extends CI_Model {
var $tabel = 'tb_keluhan';
function __construct() {
parent::__construct();
}
function GetAllCustomer() {
$hasil = $this->db->query("SELECT * FROM tb_customer ORDER BY username");
if ($hasil->num_rows() > 0) {
foreach ($hasil->result() as $row) {
$data[] = $row;
}
return $data;
}
}
function GetCustomerSession($username) {
$hasil = $this->db->query("SELECT * FROM tb_customer WHERE username='" . $username . "'");
if ($hasil->num_rows() > 0) {
foreach ($hasil->result() as $row) {
$data[] = $row;
}
return $data;
}
}
function InsertFeedback($data) {
$this->db->insert('tb_keluhan', $data);
return;
}
function InsertRating($data) {
$this->db->insert('tb_rating', $data);
return;
}
//CRUD
function insertCustomer($data) {
$this->db->insert('tb_customer', $data);
return;
}
function get_data_by_id($table, $kode) {
$this->db->where('id', $kode);
return $this->db->get($table);
}
function updateCustomer($table, $kode, $data) {
$this->db->where('id', $kode);
return $this->db->update($table, $data);
}
function del_by_id($table, $kode) {
$this->db->where('id', $kode);
$this->db->delete($table);
}
function GetAllKeluhan() {
$hasil = $this->db->query("SELECT * FROM tb_keluhan");
if ($hasil->num_rows() > 0) {
foreach ($hasil->result() as $row) {
$data[] = $row;
}
return $data;
}
}
function GetAllSudahProses() {
$hasil = $this->db->query("SELECT * FROM tb_keluhan WHERE status='SELESAI' ORDER BY status");
if ($hasil->num_rows() > 0) {
foreach ($hasil->result() as $row) {
$data[] = $row;
}
return $data;
}
}
function GetAllBelumProses() {
$hasil = $this->db->query("SELECT * FROM tb_keluhan WHERE status='BELUM' ORDER BY status");
if ($hasil->num_rows() > 0) {
foreach ($hasil->result() as $row) {
$data[] = $row;
}
return $data;
}
}
//END OF CRUD
}
?>
我控制器// CONTROLER
public function rateform($username,$id,$name) {
$rating = $this->input->post('rating');
$name2 = urldecode($name);
$data = array
(
'id' => $this->input->post('id'),
'username' => $this->input->post('username'),
'rating' => $this->input->post('rating')
);
$result = $this->login_database->InsertRating($data);
if ($result == TRUE) {
$data['message_display'] = 'Registration Successful !';
} else {
$data['message_display'] = 'Username already exist!';
}
幫我,我不能插入數據到數據庫中。 $結果alwas錯誤和數據沒有進入到數據庫 我不與錯誤
顯示所有代碼,$ data的錯誤和var_dump – calexandre
在控制器構造函數中添加此行。 '$ this-> load-> model('login_database');' –
請閱讀如何在此處編輯器中對代碼進行格式化https://meta.stackexchange.com/questions/22186/how-do-i-format-我的代碼塊 – user4419336