codeigniter Active Record

CREATE

$this->db->insert(‘table_name’,$data);

READ

$this->db->get(‘table_name’);
//SELECT * FROM table_name

$this->db->get_where(‘table_name’,array(‘id’=>$id);
//SELECT id FROM table_name

$this->db->select(‘title,content,date’);
$query = $this->db->get(‘table_name’);
//SELECT title,content,date FROM table_name

UPDATE

$this->db->where(‘id’,$id);
$this->db->update(‘table_name’,$data);
//table에서 id값이 $id인 row를 update한다.
//UPDATE table_name
//SET title='{$title}’,name='{$name}’,date='{$date}’
//WHERE id = $id
$this->db->update(‘table_name’,$data,”id = 4″);
//id가 4인 row를 update한다.

DELETE

$this->db->delete(‘table_name’,$data);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s