发生数据库错误:1146

wbrvyc0a  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(246)

**结案。**此问题不可复制或由打字错误引起。它目前不接受答案。
**想改进这个问题吗?**更新问题,使其成为堆栈溢出的主题。

两年前关门了。
改进这个问题
我尝试在表事件中显示所有数据,并与数据库中的另一个表建立关系。带codeigniter
我犯了这样的错误:
发生数据库错误错误号:1146
表'db\u wpro.kategori'不存在

SELECT event.*, kategori.kat_nama, status.stat_nama, palanggan.p_nama, tim.tim_nama FROM event INNER JOIN kategori ON kategori.kat_id = event.kat_id INNER JOIN status ON status.stat_id = event.stat_id INNER JOIN pelanggan ON pelanggan.p_id = event.p_id INNER JOIN tim ON tim.tim_id = event.tim_id

Filename: C:/xampp/htdocs/SIAPWPRO/system/database/DB_driver.php

Line Number: 691

这是我的模型:

<?php
if  (!defined('BASEPATH')) exit('No direct script access allowed');
class Event_model extends CI_Model
{
    public $table = 'event';
    public $id = 'id_event';
    public $order = 'DESC';

    public function __construct()
    {

    $this->load->database();
    }

    public function getAllEvent()
    {
        $hasil1['a']=$this->db->query("SELECT event.*, kategori.kat_nama, status.stat_nama, palanggan.p_nama, tim.tim_nama
                                       FROM event 
                                       INNER JOIN kategori ON kategori.kat_id = event.kat_id
                                       INNER JOIN status ON status.stat_id = event.stat_id
                                       INNER JOIN pelanggan ON pelanggan.p_id = event.p_id
                                       INNER JOIN tim ON tim.tim_id = event.tim_id
                                    ");

         return $hasil1['a'];
    }

控制器:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Event extends CI_Controller {
    public function __construct() {
        parent::__construct();
        $this->load->helper('url');
        $this->load->helper('form');
       // $this->load->model('Tim_Model');
        $this->load->model('Event_model');
        $this->base=$this->config->item('base_url');
    }
    public function index()
    {
        // memanggil method get semua perusahaan dari perusahaan model
        $x['data']=$this->Event_model->getAllEvent();

         $this->load->view('Event/event_list',$x);
        //$this->load->view('Tim/tim_list');
    }}

视图:

<!doctype html>
<html>
    <head>
        <title>Data Event</title> 
        <link href="<?php echo base_url().'assets/css/jquery.dataTables.min.css'?>" rel="stylesheet">

        </head>
    <body>
<?php $this->load->view('templates/header_manajer');?>
            <div class="row" style="margin-bottom: 10px">
            <div class="col-md-4">
                <h2 style="margin-top:10px">Data Event</h2>
            </div>
            <div class="col-md-4 text-right">
                <?php echo anchor(site_url('Event/create'), 'Tambah', 'class="btn btn-primary"'); ?>
        </div>
        </div>
        <div class="Notifikasi">
                            <p><b><?php echo $this->session->flashdata('InsertScc')?></b></p>
                </div>
                <div class="panel-body">
                    <table class="table table-bordered table-striped" id="mytable">
                    <thead>
                    <tr>
                    <th class="text-center">ID</th>
                    <th class="text-center">Nama</th>
                    <th class="text-center">Tanggal Persiapan</th>
                    <th class="text-center">Tanggal Mulai</th>
                    <th class="text-center">Waktu</th>
                    <th class="text-center">Lokasi</th>
                    <th class="text-center">Kategori</th>
                    <th class="text-center">Status</th>
                    <th class="text-center">Pelanggan</th>
                    <th class="text-center">Tim</th>
                    <th class="text-center">Aksi</th>
                    </tr>
                    </thead>

                    <tbody>

                        <?php

                        foreach($data->result_array() as $i):

                              $id_event=$i['id_event'];

                              $nama_event=$i['nama_event'];

                              $tglperisapan_event=$i['tglperisapan_event'];

                              $tglmulai_event=$i['tglmulai_event'];

                              $waktu_event=$i['waktu_event'];

                              $lokasi_event=$i['lokasi_event'];

                              $kat_id=$i['kat_nama'];

                              $stat_id=$i['stat_nama'];

                              $p_id=$i['p_nama'];

                              $tim_id=$i['tim_nama'];

                        ?>
                  <tr>

                        <td><?php echo $id_event;?> </td>

                        <td><?php echo $nama_event;?> </td>

                        <td><?php echo $tglperisapan_event;?> </td>

                        <td><?php echo $tglmulai_event;?> </td>

                        <td><?php echo $waktu_event;?> </td>

                        <td><?php echo $lokasi_event;?> </td>

                        <td><?php echo $kat_id;?> </td>

                        <td><?php echo $stat_id;?> </td>

                        <td><?php echo $p_id;?> </td>

                        <td><?php echo $tim_id;?> </td>

                        <td><a href="<?php echo base_url()."index.php/Karyawan/getKaryawanID/".$i['kr_id']; ?>" class="btn btn-default btn-sm">Ubah</a> | <a href="<?php echo base_url()."index.php/Karyawan/deleteKaryawan/".$i['kr_id']; ?>" class="btn btn-default btn-sm">Hapus</a> </td>

                  </tr>

                  <?php endforeach;?>

                     </tbody>
                    </table>
                </div>
            </div>
            <script src="<?php echo base_url().'assets/js/jquery-2.2.4.min.js'?>"> </script>

<script src="<?php echo base_url().'assets/js/bootstrap.js'?>"> </script>

<script src="<?php echo base_url().'assets/js/jquery.dataTables.min.js'?>"> </script>

<script src="<?php echo base_url().'assets/js/moment.js'?>"> </script>

<script>

      $(document).ready(function(){

            $('#mydata').DataTable();

      });

</script>
          </body>
          </html>

<?php $this->load->view('templates/footer'); ?>

这是我的关系数据库,在这里输入图像描述
有人能帮我解决这个错误吗^^

iklwldmw

iklwldmw1#

交叉检查你的数据库,kategori不存在。

Table 'db_wpro.kategori' doesn't exist

使用您添加的图像,我发现您的表中有拼写错误。

You are using  - kategori

In image correct name is - ketegori

请更正表名,然后重试。
谢谢

相关问题