본문으로 바로가기

데이터의 row count

$where = "grp_idx=".$grp_idx." and u_id='".$u_id."' and c_expire_date >= date_add(now(), interval -600 minute)";
$this->db->where($where);
$this->db->from($this->certify_table);
$certify_cnt = $this->db->count_all_results();

 

실행 쿼리 문자열 반환

print_r($this->db->last_query());

 

join의 예

$this->db->select("A.*, B.g_img");
$this->db->where('A.grp_idx', $grp_idx);
$this->db->where('A.g_pack_idx', $row->idx);
$this->db->from($this->goods_inout_detail_table." AS A");
$this->db->join($this->goods_table." AS B", 'A.g_barcode = B.g_barcode');
$this->db->order_by('A.idx', 'DESC');
$query2 = $this->db->get();

foreach ($query2->result() as $row2)
{
	echo $row2->idx
}