@@ -20,3 +20,240 @@ list set of data from your database :
2020 $this->mz_crud->set_config($config);
2121 $dataTable = $this->mz_crud->list_('users');
2222
23+ ##Insert
24+
25+ $config['labels'] = array( 'username'=>'Alias' , 'email'=>'Email' , 'about_me'=> 'About Me' );
26+ $config['ignor'] = array('id');
27+ $config['check_duplicate'] = array( 'username' , 'email' );
28+ $config['redirect'] = base_url().'index/crudList/';
29+ $config['inp_type'] = array('username'=>'text' , 'about_me'=>'rich_textarea');
30+
31+ $this->mz_crud->set_config($config);
32+ $insertTable = $this->mz_crud->add('users');
33+ ##Edit
34+
35+ $config['labels'] = array( 'username'=>'Alias' , 'email'=>'Email' , 'about_me'=> 'About Me' );
36+ $config['ignor'] = array('id');
37+ $config['check_duplicate'] = array( 'username' , 'email' );
38+ $config['redirect'] = base_url().'index/crudList/';
39+ $config['inp_type'] = array('username'=>'text' , 'about_me'=>'rich_textarea');
40+
41+ $this->mz_crud->set_config($config);
42+ $insertTable = $this->mz_crud->edit( $id , 'users');
43+
44+ *see the sample code for more information
45+
46+
47+ ##Preferences
48+
49+ The preferences described below .
50+
51+ Note that not all preferences are availabel for every function.
52+
53+ <table cellpadding =" 0 " cellspacing =" 1 " border =" 0 " style =" width :100% " class =" tableborder " >
54+ <tbody ><tr >
55+ <th >Preference</th >
56+ <th >Default  ; Value</th >
57+ <th >value</th >
58+ <th >Description</th >
59+ <th >Availability</th >
60+ </tr >
61+
62+ <tr >
63+ <td class =" td " ><strong >labels</strong ></td >
64+ <td class =" td " >database column label</td >
65+ <td class =" td " >array of 'column'=> ; 'label' pairs </td >
66+ <td class =" td " >Sets the label for each database column in the view</td >
67+ <td class =" td " >all</td >
68+ </tr >
69+
70+ <tr >
71+ <td class =" td " ><strong >ignor</strong ></td >
72+ <td class =" td " >None</td >
73+ <td class =" td " >array of columns</td >
74+ <td class =" td " >Sets column that should be ignored in the operation </td >
75+ <td class =" td " >all</td >
76+ </tr >
77+
78+ <tr >
79+ <td class =" td " ><strong >redirect</strong ></td >
80+ <td class =" td " >current_url()</td >
81+ <td class =" td " >string</td >
82+ <td class =" td " >Sets the redirect URL after operation (edit <br >
83+ , insert ) </td >
84+ <td class =" td " >add , edit </td >
85+ </tr >
86+
87+ <tr >
88+ <td class =" td " ><strong >edit_url</strong ></td >
89+ <td class =" td " >current_url()</td >
90+ <td class =" td " >string</td >
91+ <td class =" td " >Sets the Url to Edit function</td >
92+ <td class =" td " >list_</td >
93+ </tr >
94+
95+
96+ <tr >
97+ <td class =" td " ><strong >fail_url</strong ></td >
98+ <td class =" td " >current_url()</td >
99+ <td class =" td " >string</td >
100+ <td class =" td " >Sets the redirect URL after operation fails</td >
101+ <td class =" td " >add , edit </td >
102+ </tr >
103+
104+
105+ <tr >
106+ <td class =" td " ><strong >inp_type</strong ></td >
107+ <td class =" td " >type="text"</td >
108+ <td class =" td " >array of 'column'=> ; 'input type' pairs </td >
109+ <td class =" td " >Sets the Html input type for each column.</td >
110+ <td class =" td " >all</td >
111+ </tr >
112+
113+ <tr >
114+ <td class =" td " ><strong >options</strong ></td >
115+ <td class =" td " >empty array</td >
116+ <td class =" td " >2d array of 'column'=> ; array('option label'=> ; 'option value') </td >
117+ <td class =" td " >Sets the selectable options for input_type of (select , checkbox , radio )</td >
118+ <td class =" td " >all</td >
119+ </tr >
120+
121+
122+ <tr >
123+ <td class =" td " ><strong >check_duplicate</strong ></td >
124+ <td class =" td " >None</td >
125+ <td class =" td " >array of columns</td >
126+ <td class =" td " >checks the database for duplicate before insert or edit </td >
127+ <td class =" td " >all</td >
128+ </tr >
129+
130+ <tr >
131+ <td class =" td " ><strong >md_options</strong ></td >
132+ <td class =" td " >None</td >
133+ <td class =" td " >array( 'add' , 'edit' , 'delete')</td >
134+ <td class =" td " >Sets the moderating options for a list .</td >
135+ <td class =" td " >list_</td >
136+ </tr >
137+
138+ <tr >
139+ <td class =" td " ><strong >id_fild</strong ></td >
140+ <td class =" td " >id</td >
141+ <td class =" td " >string</td >
142+ <td class =" td " >sets the id colum in database</td >
143+ <td class =" td " >edit</td >
144+ </tr >
145+
146+ <tr >
147+ <td class =" td " ><strong >per_page</strong ></td >
148+ <td class =" td " >0</td >
149+ <td class =" td " >int</td >
150+ <td class =" td " > sets the per page option for pagination ( 0 == no pagination )</td >
151+ <td class =" td " >list_</td >
152+ </tr >
153+
154+ <tr >
155+ <td class =" td " ><strong >search</strong ></td >
156+ <td class =" td " >empty array</td >
157+ <td class =" td " >array of columns</td >
158+ <td class =" td " >sets the searchable colums and adds a search option to the list </td >
159+ <td class =" td " >list_</td >
160+ </tr >
161+
162+
163+ <tr >
164+ <td class =" td " ><strong >sort</strong ></td >
165+ <td class =" td " >empty array</td >
166+ <td class =" td " >array of columns</td >
167+ <td class =" td " >sets the sortable colums and adds a sort option to the list </td >
168+ <td class =" td " >list_</td >
169+ </tr >
170+
171+
172+
173+
174+ <tr >
175+ <td class =" td " ><strong >documentready</strong ></td >
176+ <td class =" td " >ampty array</td >
177+ <td class =" td " >array</td >
178+ <td class =" td " >javascript commands to be run on document ready </td >
179+ <td class =" td " >all</td >
180+ </tr >
181+
182+ <tr >
183+ <td class =" td " ><strong >lang</strong ></td >
184+ <td class =" td " >array('file'=> ; 'crud' , 'folder'=> ; 'crud')</td >
185+ <td class =" td " >array</td >
186+ <td class =" td " >sets the address for language file</td >
187+ <td class =" td " >all</td >
188+ </tr >
189+
190+ </tbody ></table >
191+
192+ ##sample code
193+
194+ lets say we have a table called "users"
195+ users : id , username , email , recive_newsletter , profile
196+
197+ class index extends CI_Controller {
198+
199+ function crudList(){
200+
201+ $this->load->library('mz_crud');
202+
203+ $config['ignor'] = array('id' , 'recive_newsletter' , 'profile' );
204+ $config['check_duplicate'] = array( 'username' , 'email');
205+ $config['edit_url'] = base_url().'index/crudEdit/';
206+ $config['md_options'] = array( 'add' , 'edit' , 'delete');
207+ $config['labels'] = array( 'username'=>'UserName' , 'email'=>'Email);
208+ $config['per_page'] = 2;
209+ $config['search'] = array( 'username' , 'email');
210+ $config['sort'] = array( 'username');
211+
212+ $this->mz_crud->set_config($config);
213+ echo $this->mz_crud->list_('users');
214+
215+ }
216+
217+
218+ function crudInsert(){
219+
220+ $this->load->library('mz_crud');
221+
222+ $config['labels'] = array('username'=>'UserName' , 'email'=>'Email' , 'recive_newsletter'=>'would you like to recive our newsletter' , 'profile'=>'Choose how you share information on your profile ?');
223+ $config['ignor'] = array('id');
224+ $config['check_duplicate'] = array( 'username' , 'email' );
225+ $config['redirect'] = base_url().'index/crudList/';
226+ $config['inp_type'] = array('newsletter'=>'select' , 'profile'=>'radio');
227+ $config['options'] = array('newsletter'=>array('Yes , i do'=>'1' , 'No , thanx '=>'0' ) ,
228+ 'profile'=>array('i want a public profile '=>'public' , 'i want a private profile'=>'private' ));
229+ $config['documentready'] = array('alert("Please fill in all fields ");');
230+
231+ $this->mz_crud->set_config($config);
232+ echo $this->mz_crud->add('users');
233+
234+ }
235+
236+
237+
238+
239+ function crudEdit( $id = 0 ){
240+
241+ $this->load->library('mz_crud');
242+
243+ $config['labels'] = array('username'=>'UserName' , 'email'=>'Email' , 'recive_newsletter'=>'would you like to recive our newsletter' , 'profile'=>'Choose how you share information on your profile ?');
244+ $config['ignor'] = array('id');
245+ $config['check_duplicate'] = array( 'username' , 'email' );
246+ $config['redirect'] = base_url().'index/crudList/';
247+ $config['inp_type'] = array('newsletter'=>'select' , 'profile'=>'radio');
248+ $config['options'] = array('newsletter'=>array('Yes , i do'=>'1' , 'No , thanx '=>'0' ) ,
249+ 'profile'=>array('i want a public profile '=>'public' , 'i want a private profile'=>'private' ));
250+ $config['documentready'] = array('alert("Please fill in all fields ");');
251+
252+ $this->mz_crud->set_config($config);
253+ echo $this->mz_crud->edit( $id , 'users');
254+
255+ }
256+
257+
258+ }
259+
0 commit comments