Skip to content

Instantly share code, notes, and snippets.

@jrvaja
Created June 27, 2012 07:04
Show Gist options
  • Save jrvaja/3002149 to your computer and use it in GitHub Desktop.
Save jrvaja/3002149 to your computer and use it in GitHub Desktop.
CodeIgnite:model_activeRecords1
class Site_model extends CI_Model {
//Select all
function get_records(){
$query=$this->db->get('data');
return $query->result();
}
//Add Record
function add_record(){
$data=array(
'title'=>$this->input->post('title'),
'contents'=>$this->input->post('contents')
);
$this->db->insert('data',$data);
return;
}
//Update
function update_record(){
$data = array(
'title'=>'This is new title2',
'contents'=>'This is new Content2'
);
$this->db->where('id',4);
$this->db->update('data',$data);
}
//Delete row
function delete_row(){
$this->db->where('id',$this->uri->segment(3));
$this->db->delete('data');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment