diff --git a/snippets/codeigniter.snippets b/snippets/codeigniter.snippets index 5dcd2da..0fabcc5 100644 --- a/snippets/codeigniter.snippets +++ b/snippets/codeigniter.snippets @@ -2,24 +2,72 @@ # Controller snippet ci_controller - class ${1:ClassName} extends CI_Controller { - function __construct() { + db->get($table)->result(); + } + + public function getRow($id) + { + return $this->db->get_where($table, array('id', $id))->result(); + } + + public function insert($data) + { + if($this->db->insert($table, $data)) + return true; + else + return false; + } + + public function update($id, $data) + { + if($this->db->where('id', $id)->update($table, $data)) + return true; + else + return false; + } + } # Load view snippet ci_load-view $this->load->view("${1:view_name}", $${2:data});${3}