Created
June 27, 2012 07:04
-
-
Save jrvaja/3002149 to your computer and use it in GitHub Desktop.
CodeIgnite:model_activeRecords1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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