Iam坚持这个问题(搜索和测试仍然失败)。 我使用codeigniter(新手)。我不知道这个错误在哪里出现了问题。
A PHP Error was encountered
Severity: 4096
Message: Object of class CI_DB_mysql_result could not be converted to string
Filename: controllers/bpjs_kesehatan.php
Line Number: 627
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at E:\xampp\htdocs\csi\system\core\Exceptions.php:185)
Filename: core/Common.php
Line Number: 442
A Database Error Occurred
The query you submitted is not valid.
Filename: E:\xampp\htdocs\csi\system\database\DB_driver.php
Line Number: 257
我的控制器
function laporan_form34()
{
$bagianWhere = "";
if (isset($_POST['check_nik']))
{
$nik = $this->input->post('nik');
if (empty($bagianWhere))
{
$bagianWhere .= "bk.nik like '%$nik%'";
}
}
if (isset($_POST['check_npp']))
{
$npp = $this->input->post('npp');
if (empty($bagianWhere))
{
$bagianWhere .= "b.npp = '$npp'";
}
else
{
$bagianWhere .= " AND b.npp = '$npp'";
}
}
if (isset($_POST['check_kk']))
{
$kk = $this->input->post('kk');
if (empty($bagianWhere))
{
$bagianWhere .= "bk.no_kk like '%$kk%'";
}
else
{
$bagianWhere .= "AND bk.no_kk like '%$kk%'";
}
}
if (empty($bagianWhere))
{
$this->session->set_flashdata('flash_messages', 'ERROR : Minimal salah satu kriteria harus diisi !');
redirect( base_url() . 'bpjs_kesehatan/form34');
}
else
{
$result_criteria = $this->app_model->manualQuery("select b.nik,b.hubkel
from biodata_karyawan bk left join bpjs b
on b.nik = bk.nik where bk.status_karyawan = 'Aktif' and " . $bagianWhere ." order by b.nik");
}
//show data to view
$bc['dt_karyawan'] = $this->db->query("$result_criteria");
$this->load->view('bpjs_kesehatan/laporan_form34',$bc);
}
我的观点
foreach($dt_karyawan->result_array() as $row)
{
$hubkel = $row['hubkel'];
$nik = $row['nik'];
if($hubkel=='pegawai')
{
//HUBKEL PEGAWAI
$query_pegawai = "select bk.no_kk as 'no_2',bk.nik as 'no_3',bk.nama as 'no_4',
'1' as 'no_5',bk.tempat_lahir as 'no_6',bk.tgl_lahir as 'no_7',bk.jenis_kelamin as 'no_8','1' as 'no_9',
bk.nama_ibu as 'no_10',bk.alamat as 'no_11',bk.rt as 'no_12',bk.rw as 'no_13',bk.kodepos as 'no_14',
bk.kode_kecamatan as 'no_15',bk.nama_kecamatan as 'no_16',
bk.kode_desa as 'no_17',bk.nama_desa as 'no_18',b.kode_faskes as 'no_19',b.nama_faskes as 'no_20',
b.kode_faskes_gigi as 'no_21',b.nama_faskes_gigi as 'no_22',bk.no_hp as 'no_23',
bk.email as 'no_24',b.npp as 'no_25','security' as 'no_26','2' as 'no_27',b.kelas_rawat as 'no_28',
bk.tgl_masuk as 'no_29',
'-' as 'no_30',bk.kewarganegaraan as 'no_31',b.asuransilainnya_nopolis as 'no_32',
b.asuransilainnya_namaasuransi as 'no_33',b.no_npwp as 'no_34',b.no_passport as 'no_35'
from biodata_karyawan bk left join bpjs b on bk.nik=b.nik where b.nik='$nik'";
}
if($hubkel=='istri')
{
//HUBKEL ISTRI
$query_istri = "select bk.no_kk_pasangan as 'no_2',bk.nik as 'no_3',bk.sp_nama_ibu as 'no_4',
'3' as 'no_5',bk.sp_tmptlhr_ibu as 'no_6',bk.sp_tgllhr_ibu as 'no_7','2' as 'no_8','2' as 'no_9',
bk.sp_namaibukandung_ibu as 'no_10',bk.alamat_pasangan as 'no_11',bk.rt_pasangan as 'no_12',
bk.rw_pasangan as 'no_13',bk.kodepos_pasangan as 'no_14',
bk.kode_kecamatan_pasangan as 'no_15',bk.nama_kecamatan_pasangan as 'no_16',
bk.kode_desa_pasangan as 'no_17',bk.nama_desa_pasangan as 'no_18',b.kode_faskes as 'no_19',
b.nama_faskes as 'no_20',
b.kode_faskes_gigi as 'no_21',b.nama_faskes_gigi as 'no_22','-' as 'no_23',
'-' as 'no_24',b.npp as 'no_25','-' as 'no_26','-' as 'no_27',b.kelas_rawat as 'no_28','-' as 'no_29',
'-' as 'no_30',bk.kewarganegaraan as 'no_31',b.asuransilainnya_nopolis as 'no_32',
b.asuransilainnya_namaasuransi as 'no_33',b.no_npwp as 'no_34',b.no_passport as 'no_35'
from biodata_karyawan bk left join bpjs b on bk.nik=b.nik where b.nik='$nik'";
}
if($hubkel=='suami')
{
//HUBKEL SUAMI
$query_suami = "select bk.no_kk_pasangan as 'no_2',bk.nik as 'no_3',bk.sp_nama_ayah as 'no_4',
'2' as 'no_5',bk.sp_tmptlhr_ayah as 'no_6',bk.sp_tgllhr_ayah as 'no_7','3' as 'no_8','2' as 'no_9',
bk.sp_namaayahkandung_ibu as 'no_10',bk.alamat_pasangan as 'no_11',bk.rt_pasangan as 'no_12',
bk.rw_pasangan as 'no_13',bk.kodepos_pasangan as 'no_14',
bk.kode_kecamatan_pasangan as 'no_15',bk.nama_kecamatan_pasangan as 'no_16',
bk.kode_desa_pasangan as 'no_17',bk.nama_desa_pasangan as 'no_18',b.kode_faskes as 'no_19',
b.nama_faskes as 'no_20',
b.kode_faskes_gigi as 'no_21',b.nama_faskes_gigi as 'no_22','-' as 'no_23',
'-' as 'no_24',b.npp as 'no_25','-' as 'no_26','-' as 'no_27',b.kelas_rawat as 'no_28','-' as 'no_29',
'-' as 'no_30',bk.kewarganegaraan as 'no_31',b.asuransilainnya_nopolis as 'no_32',
b.asuransilainnya_namaasuransi as 'no_33',b.no_npwp as 'no_34',b.no_passport as 'no_35'
from biodata_karyawan bk left join bpjs b on bk.nik=b.nik where b.nik='$nik'";
}
if(!empty($query_pegawai))
{
foreach($query_pegawai->result() as $data)
{
echo '<tr align="center">';
echo '<td>'.$no.'</td>';
echo '<td>'.$kutip.$data->no_2.'</td>';
echo '<td>'.$kutip.$data->no_3.'</td>';
echo '<td>'.$data->no_4.'</td>';
echo '<td>'.$data->no_5.'</td>';
echo '<td>'.$data->no_6.'</td>';
echo '<td>'.$kutip.$data->no_7.'</td>';
echo '<td>'.$data->no_8.'</td>';
echo '<td>'.$data->no_9.'</td>';
echo '<td>'.$data->no_10.'</td>';
echo '<td>'.$data->no_11.'</td>';
echo '<td>'.$kutip.$data->no_12.'</td>';
echo '<td>'.$kutip.$data->no_13.'</td>';
echo '<td>'.$kutip.$data->no_14.'</td>';
echo '<td>'.$kutip.$data->no_15.'</td>';
echo '<td>'.$data->no_16.'</td>';
echo '<td>'.$kutip.$data->no_17.'</td>';
echo '<td>'.$data->no_18.'</td>';
echo '<td>'.$kutip.$data->no_19.'</td>';
echo '<td>'.$data->no_20.'</td>';
echo '<td>'.$data->no_21.'</td>';
echo '<td>'.$data->no_22.'</td>';
echo '<td>'.$kutip.$data->no_23.'</td>';
echo '<td>'.$data->no_24.'</td>';
echo '<td>'.$kutip.$data->no_25.'</td>';
echo '<td>'.$data->no_26.'</td>';
echo '<td>'.$data->no_27.'</td>';
echo '<td>'.$data->no_28.'</td>';
echo '<td>'.$kutip.$data->no_29.'</td>';
echo '<td>'.$data->no_30.'</td>';
echo '<td>'.$data->no_31.'</td>';
echo '<td>'.$kutip.$data->no_32.'</td>';
echo '<td>'.$data->no_33.'</td>';
echo '<td>'.$kutip.$data->no_34.'</td>';
echo '<td>'.$kutip.$data->no_35.'</td>';
echo '</tr>';
}
}
if(!empty($query_istri))
{
foreach($query_istri->result() as $data)
{
echo '<tr align="center">';
echo '<td>'.$no.'</td>';
echo '<td>'.$kutip.$data->no_2.'</td>';
echo '<td>'.$kutip.$data->no_3.'</td>';
echo '<td>'.$data->no_4.'</td>';
echo '<td>'.$data->no_5.'</td>';
echo '<td>'.$data->no_6.'</td>';
echo '<td>'.$kutip.$data->no_7.'</td>';
echo '<td>'.$data->no_8.'</td>';
echo '<td>'.$data->no_9.'</td>';
echo '<td>'.$data->no_10.'</td>';
echo '<td>'.$data->no_11.'</td>';
echo '<td>'.$kutip.$data->no_12.'</td>';
echo '<td>'.$kutip.$data->no_13.'</td>';
echo '<td>'.$kutip.$data->no_14.'</td>';
echo '<td>'.$kutip.$data->no_15.'</td>';
echo '<td>'.$data->no_16.'</td>';
echo '<td>'.$kutip.$data->no_17.'</td>';
echo '<td>'.$data->no_18.'</td>';
echo '<td>'.$kutip.$data->no_19.'</td>';
echo '<td>'.$data->no_20.'</td>';
echo '<td>'.$data->no_21.'</td>';
echo '<td>'.$data->no_22.'</td>';
echo '<td>'.$kutip.$data->no_23.'</td>';
echo '<td>'.$data->no_24.'</td>';
echo '<td>'.$kutip.$data->no_25.'</td>';
echo '<td>'.$data->no_26.'</td>';
echo '<td>'.$data->no_27.'</td>';
echo '<td>'.$data->no_28.'</td>';
echo '<td>'.$kutip.$data->no_29.'</td>';
echo '<td>'.$data->no_30.'</td>';
echo '<td>'.$data->no_31.'</td>';
echo '<td>'.$kutip.$data->no_32.'</td>';
echo '<td>'.$data->no_33.'</td>';
echo '<td>'.$kutip.$data->no_34.'</td>';
echo '<td>'.$kutip.$data->no_35.'</td>';
echo '</tr>';
}
}
}
$ dt_karyawan有很多记录。但我必须再次使用查询选择hubkel =(pegawai,suami,istri)的数据库。 哪里有我的问题? 感谢你的时间。