A :
Hi use this code
//How to set flash data
$this->session->set_flashdata('alert', 'This is my message');
// After that you need to used redirect function goes on previous page
redirect("students/studentList");
// How to get flash data on view
$this->session->flashdata('alert')
A :
$cookie_name = "UserDetails";
$cookie_value = json_encode($sessionData);
setcookie($cookie_name, $cookie_value, time() + (86400) * (30 * 365), "/");
A :
Use this Sample code :
$update = array(
'advance_paid' => $data['TXNAMOUNT'],
'payment_mode' => 'PONLINE',
'txn_id' => $data['BANKTXNID']
);
$this->db->where("id",$data['Id']);
$query = $this->db->update("payment_table",$update);
if($this->db->affected_rows()){
return true;
}else{
return false;
}
Yes $this->db->affected_rows() always returns TRUE in CodeIgniter.
A :
Use follow code for delete operation in CodeIgniter.
StudentController class
function delete_student(){
$student_id = $this->input->get("studentId");
$result = $this->StudentModel->delete_student($student_id);
if($result)
redirect(base_url."StudentController/studentlist");
}
StudentModel class
//function to Delete selected record from table name students
function delete_student($id){
$this->db->where("student_id", $id);
$this->db->delete("students");
if($this->db->affected_rows()){
return true;
}
}
}
A :
get current class name codeigniter
//get current class using following code
$this->router->fetch_class();
//get current class method using
$this->router->fetch_method();
A :
$this->load->library("user_agent");
if ($this->agent->is_referral())
{
echo $this->agent->referrer();
}
A :
use this to get user ip address
$this->input->ip_address();
A :
$this->db->where("id", $id);
$this->db->set("set_row", "`set_row`+ 1", FALSE);
$this->db->update("article");
A :
You can modify just the two lines:
$this->db->where('q.question_cat_id',$cat_id);
$this->db->or_where('q.question_sub_id',$cat_id);
replace where_or with or_where
A :
Distroy cookies in php
if (isset($_COOKIE['remember_user'])) {
unset($_COOKIE['Hello']);
unset($_COOKIE['HelloTest1']);
setcookie('Hello', null, -1, '/');
setcookie('HelloTest1', null, -1, '/');
return true;
} else {
return false;
}