MySql Query for Codeigniter

Select Query

$clearEmiSql = “SELECT * FROM `tbl_mortgage_new_emi` WHERE `ID` >= ‘”.$emi_no.”‘ AND `emi_clear` = ‘1’ AND `mortgage_id` = ‘”.$mort_id.”‘”;
$clearEmiSql = $this->db->query($clearEmiSql);
$clearEmiResData = $clearEmiSql->result_array();

echo $this->db->last_query(); die;

Insert Query

$data_newEmi = array(
‘total_emi’=>$emi_amount,
‘mortgage_id’=>$mort_id,
’emi_date’=>$date_new
);
$this->mortgage_model->insert(‘tbl_mortgage_new_emi’, $data_newEmi);

Delete and Update Query

$sqlDeleteRow = “Delete from `tbl_mortgage_new_emi` where `mortgage_id` = ‘”.$mort_id.”‘ order by `ID` desc limit 1″;
$this->db->query($sqlDeleteRow);

Read More
Codeigniter, PHP