-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