From 5271ea5a1d8710bfd123801fb45742ff3a60a3e6 Mon Sep 17 00:00:00 2001 From: rtorralba Date: Fri, 7 Nov 2014 15:48:03 +0100 Subject: [PATCH] improved some snippets --- snippets/codeigniter.snippets | 58 ++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 5 deletions(-) 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}