如何在视图codeignitier中显示我的查询

时间:2016-12-28 05:10:18

标签: codeigniter

这是我的控制器

public function ajax_pasien($Kode)
{
    $data = $this->infokamar->get_by_id1($Kode);
    echo json_encode($data);
}

这是我的模特

public function get_by_id1($Kode)
{
    $sql = "select a.norm, b.nama as pasien, b.alamat, c.tanggal, c.tanggal1, f.jumlah, f.biaya from TTKunjungan a inner join TMPasien b on A.norm = b.norm inner join TTKunjunganDetail c on A.Kode = c.kodekunjungan inner join TMTrfTindakan d on c.kodetindakan = d.Kode inner join TMTrfLayanan e on d.kodelayanan = e.Kode left join (select kodett, sum(jumlah) as jumlah, sum(biaya) as biaya from TTKunjunganDetail where kodett is not null group by kodett) f on  c.Kode = F.kodett Where e.kodeklasifikasi = 2 and c.tanggal1 is null and c.kodett is null and c.kodetindakan = '{$Kode}'";
    $query = $this->db->query($sql);
    return($query->result_array());
}

这是我的观点,但没有显示

enter image description here

2 个答案:

答案 0 :(得分:1)

检查查询的最佳方法有两种:

<强> 1。打印上一个查询使用以下代码打印上次执行的查询

 - (IBAction)paste:sender
{
    NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
    NSArray *classArray = [NSArray arrayWithObject:[NSImage class]];
    NSDictionary *options = [NSDictionary dictionary];
    BOOL ok = [pasteboard canReadObjectForClasses:classArray options:options];
    if (ok)
    {
       NSArray *objectsToPaste = [pasteboard readObjectsForClasses:classArray options:options];
       NSImage *image = [objectsToPaste objectAtIndex:0];
      [imageView setImage:image];
    }
}

<强> 2。启用探查器确保输出类已加载/自动加载。只需在控制器的构造函数中启用探查器,方法是添加以下代码并在渲染页面后查看魔术

<?php echo $this>db->last_query() ?>

-Cheers

答案 1 :(得分:0)

在控制器中将数据从控制器发送到您的相应视图。

public function ajax_pasien($Kode)
    {
        $data = $this->infokamar->get_by_id1($Kode);
        //echo json_encode($data);
        $this->load->view('view_name',$data);
    }