我创建了名为 Categori.php 的库文件,但不知何故我无法加载我创建的库。
这是库代码:
class Kategori {
public function panggil_kategori($id_jenis)
{
$CI =& get_instance();
$CI->load->model('ticketing_model');
$idjenis = $CI->ticketing_model->getone_kategori($id_jenis);
return $idjenis;
}
}
这是控制器代码:
public function browse_ticketing()
{
$this->load->library('kategori');
$this->data['data']=$this->ticketing_model->get_all();
$this->data['body']='data_ticketing';
$this->load->view('welcome_ticketing',$this->data);
}
这是查看代码:
<table class="table table-condensed table-bordered table-hover table-striped" border="1">
<h4>Open</h4>
<tr>
<th>No</th>
<th>Judul</th>
<th>Kategori</th>
<th>Prioritas</th>
</tr>
<?php
$no = 1;
foreach($data as $row){
?>
<tr>
<td><?php echo $no++ ?></td>
<td><?php echo $row['judul'] ?></td>
<td><?php echo panggil_kategori($row['id_jenis']); ?></td>
<td><?php echo $row['prioritas'] ?></td>
</tr>
<?php
}
?>
这是模型代码:
function getone_kategori($id_jenis)
{
$this->db->select('nama_jenis');
$this->db->where('id_jenis', $id_jenis);
$query = $this->db->get('jenis_user');
return $query->row();
}
当我尝试运行我的代码时,答案是致命错误:在第 18 行的 C:\xampp\htdocs\helpdesk\application\views\data_ticketing.php 中调用未定义函数 panggil_kategori() ..