1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
# Based on nebjak/snipmate.vim/snippets/php.snippets
# Controller
snippet ci_controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class ${1:ClassName} extends CI_Controller
{
function __construct()
{
parent::__construct();
${2:// code...}
}
function ${3:index}()
{
${4:// code...}
}
}
# Model
snippet ci_model
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class ${1:ClassName_model} extends CI_Model
{
function __construct()
{
parent::__construct();
${2:// code...}
}
}
snippet ci_model_crudl
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class ${1:ClassName_model} extends CI_Model
{
private $table = '${2:table_name}';
function __construct()
{
parent::__construct();
${3:// code...}
}
public function create($data)
{
if($this->db->insert($this->table, $data))
return true;
else
return false;
}
public function read($id)
{
return $this->db->get_where($this->table, array('id', $id))->result();
}
public function update($id, $data)
{
if($this->db->update($this->table, $data, array('id' => $id)))
return true;
else
return false;
}
public function delete($id)
{
if(is_array($id))
{
$this->db->trans_start();
foreach($id as $elem)
$this->db->delete($this->table, array('id' => $elem));
$this->db->trans_complete();
}
else
{
if($this->db->delete($this->table, array('id' => $id)))
return true;
else
return false;
}
}
public function listRows($limit = null, $offset = 0)
{
if(!is_null($limit))
$this->db->limit($limit, $offset);
return $this->db->get($this->table)->result();
}
}
# Load view
snippet ci_load-view
$this->load->view("${1:view_name}", $${2:data});${3}
# DB Class snippets
snippet ci_db-insert
$this->db->insert("${1:table}", $${2:data});${3}
snippet ci_db-select
$this->db->select("${1:id, ...}");${2}
snippet ci_db-from
$this->db->from("${1:table}");${2}
snippet ci_db-join
$this->db->join("${1:table}", "${2:condition}", "${3:type}");${4}
snippet ci_db-where
$this->db->where("${1:key}", "${2:value}");${3}
snippet ci_db-or_where
$this->db->or_where("${1:key}", "${2:value}");${3}
snippet ci_db-get
$this->db->get("${1:table}", ${2:limit}, ${3:offset});${4}
snippet ci_db-delete
$this->db->delete("${1:table}", "${2:where}");${3}
snippet ci_db-update
$this->db->update("${1:table}", $${2:set}, $${3:where});${4}
# Input Class snippets
snippet ci_input-post
$this->input->post("${1:index}");${2}
snippet ci_input-get
$this->input->get("${1:index}");${2}
snippet ci_input-cookie
$this->input->cookie("${1:index}");${2}
snippet ci_input-server
$this->input->server("${1:index}");${2}
snippet ci_input-user_agent
$this->input->user_agent();${1}
snippet ci_input-is_ajax_request
$this->input->is_ajax_request();${1}
snippet ci_input-is_cli_request
$this->input->is_cli_request();${1}
# Form Validation Class and Form Helper snippets
snippet ci_form_validation-set_rules
$this->form_validation->set_rules("${1:field}", "${2:label}", "${3:trim|required}");${4}
snippet ci_form_open
form_open("${1:action}");${2}
snippet ci_form_open_multipart
form_open_multipart("${1:action}");${2}
snippet ci_form_hidden
form_hidden("${1:name}", "${2:value}");${3}
snippet ci_form_input
form_input("${1:name}", "${2:value}");${3}
snippet ci_form_password
form_password("${1:name}", "${2:value}");${3}
snippet ci_form_upload
form_upload("${1:name}", "${2:value}");${3}
snippet ci_form_textarea
form_textarea("${1:name}", "${2:value}");${3}
snippet ci_form_dropdown
form_dropdown("${1:name}", $${2:options}, $${3:selected);${4}
snippet ci_form_checkbox
form_checkbox("${1:name}", "${2:value}");${3}
snippet ci_form_radio
form_radio("${1:name}", "${2:value}");${3}
snippet ci_form_submit
form_submit("${1:name}", "${2:value}");${3}
snippet ci_form_reset
form_reset("${1:name}", "${2:value}");${3}
snippet ci_form_button
form_button("${1:name}", "${2:value}");${3}
snippet ci_form_label
form_label("${1:label text}", "${2:id}");${3}
snippet ci_form_close
form_close();${1}
snippet ci_validation_errors
validation_errors();${1}
# Session Class snippets
snippet ci_session_userdata
$this->session->userdata("${1:item}");${2}
snippet ci_session_set_userdata
$this->session->set_userdata($${1:array});${2}
snippet ci_session_flashdata
$this->session->flashdata("${1:item}");${2}
snippet ci_session_set_flashdata
$this->session->set_flashdata("${1:item}", "${2:value}");${3}
|