$sql4 = " SELECT *, sum(pay) as mileage_pay , count(*) mileage_cnt FROM table1 ;
$query4 = $this->db->query($sql4);
$result4 = $query4->result();
if(!$result4){
$mileage_money = "0"; //
$mileage_money_cnt = "0"; //
}else {
$mileage_money = $query4->row()->mileage_pay;
$mileage_money_cnt = $query4->row()->mileage_cnt;
}
이런식으로 만들어서 필드에 있는 값만 가져오려고 했더니
검색결과가 NULL 이 나와서
위에 에러 메세지가 출력되었습니다.
Call to a member function row() on a non-object in
그래서 아래처럼 코드를 변경하였습니다.
$sql4 = " SELECT *, sum(pay) as mileage_pay , count(*) mileage_cnt FROM table1 ;
$query4 = $this->db->query($sql4);
$result4 = $query4->result();
if(!$result4){
$mileage_money = "0"; //
$mileage_money_cnt = "0"; //
}else {
$row = $query4->row_array();
if($row['mileage_pay'] != ""){
$mileage_money = $row['mileage_pay'];
}
if($row['mileage_cnt'] != ""){
$mileage_money_cnt = $row['mileage_cnt'];
}
}