menu

Questions & Answers

Trying to get count of column on my db, always get error Undefined index

Here's my code, i found error Undefined index

$db = \Config\Database::connect();

$data = $db->table('umt_anakpetak');
$data->select('umt_anakpetak.kode_anak_petak as anakpetak,
                anak_petak, umt_anakpetak.luas as luasanakpetak, 
                luas_ht, umt_cucupetak.kode_cucu_petak as cupet, 
                umt_cupet_tnm.kode_cupet_tnm as cupettnm, 
                jenis_lokal, inventarisasi_umt.kode_inven_umt as invenumt, 
                inventarisasi_pu.kode_inven_pu as kodeinvenpu, 
                jumlah_pohon, lbds, volume, c, d, n');

$data->join('umt_cucupetak', 'umt_cucupetak.kode_anak_petak = umt_anakpetak.kode_anak_petak');
$data->join('umt_cupet_tnm', 'umt_cupet_tnm.kode_cucu_petak = umt_cucupetak.kode_cucu_petak');
$data->join('inventarisasi_umt', 'inventarisasi_umt.kode_cupet_tnm  = umt_cupet_tnm.kode_cupet_tnm');
$data->join('inventarisasi_pu', 'inventarisasi_pu.kode_inven_umt  = inventarisasi_umt.kode_inven_umt');
$data->join('inventarisasi_umt_ukurkayu', 'inventarisasi_umt_ukurkayu.kode_inven_pu  = inventarisasi_pu.kode_inven_pu');
$data->where('umt_anakpetak.id', $id);
$query = $data->get();
// $query1 = $data->countAllResults();

$data1 = $query->getResultArray();
$data2 = $query->getRowArray();
$data3 = $query->getResult();
$data3 = $query->getRow();

$jumlahpu = $data1['kodeinvenpu'];
$a = count($jumlahpu);

and i try to get number of count of my collumn

Comments:
2023-01-17 18:34:54
$data1['kodeinvenpu']; does not exist
2023-01-17 18:34:54
count($data1) will tell you how many rows were returned, every row will contain the kodeinvenpu column
Answers(0) :