@@ -203,20 +203,20 @@ discard block |
||
203 | 203 | |
204 | 204 | if ( empty( $fields ) ) |
205 | 205 | { |
206 | - // If we have a model, we can get our fields from there |
|
207 | - if (! empty($this->options['model'])) |
|
208 | - { |
|
209 | - $fields = $this->getFieldsFromModel( $this->options['model'] ); |
|
210 | - |
|
211 | - if (empty($fields)) |
|
212 | - { |
|
213 | - return NULL; |
|
214 | - } |
|
215 | - } |
|
216 | - else |
|
217 | - { |
|
218 | - return NULL; |
|
219 | - } |
|
206 | + // If we have a model, we can get our fields from there |
|
207 | + if (! empty($this->options['model'])) |
|
208 | + { |
|
209 | + $fields = $this->getFieldsFromModel( $this->options['model'] ); |
|
210 | + |
|
211 | + if (empty($fields)) |
|
212 | + { |
|
213 | + return NULL; |
|
214 | + } |
|
215 | + } |
|
216 | + else |
|
217 | + { |
|
218 | + return NULL; |
|
219 | + } |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | $fields = explode( ' ', $fields ); |
@@ -277,36 +277,36 @@ discard block |
||
277 | 277 | |
278 | 278 | //-------------------------------------------------------------------- |
279 | 279 | |
280 | - private function getFieldsFromModel( $model ) |
|
281 | - { |
|
282 | - $this->load->model($model); |
|
280 | + private function getFieldsFromModel( $model ) |
|
281 | + { |
|
282 | + $this->load->model($model); |
|
283 | 283 | |
284 | - if (! $this->db->table_exists( $this->$model->table() )) |
|
285 | - { |
|
286 | - return ''; |
|
287 | - } |
|
284 | + if (! $this->db->table_exists( $this->$model->table() )) |
|
285 | + { |
|
286 | + return ''; |
|
287 | + } |
|
288 | 288 | |
289 | - $fields = $this->db->field_data( $this->$model->table() ); |
|
289 | + $fields = $this->db->field_data( $this->$model->table() ); |
|
290 | 290 | |
291 | - $return = ''; |
|
291 | + $return = ''; |
|
292 | 292 | |
293 | - // Prepare the fields in a string format like |
|
294 | - // it would have been passed on the CLI |
|
295 | - foreach ($fields as $field) |
|
296 | - { |
|
297 | - $temp = $field->name .':'. $field->type; |
|
293 | + // Prepare the fields in a string format like |
|
294 | + // it would have been passed on the CLI |
|
295 | + foreach ($fields as $field) |
|
296 | + { |
|
297 | + $temp = $field->name .':'. $field->type; |
|
298 | 298 | |
299 | - if (! empty($field->max_length)) |
|
300 | - { |
|
301 | - $temp .= ':'. $field->max_length; |
|
302 | - } |
|
299 | + if (! empty($field->max_length)) |
|
300 | + { |
|
301 | + $temp .= ':'. $field->max_length; |
|
302 | + } |
|
303 | 303 | |
304 | - $return .= ' '. $temp; |
|
305 | - } |
|
304 | + $return .= ' '. $temp; |
|
305 | + } |
|
306 | 306 | |
307 | - return $return; |
|
308 | - } |
|
307 | + return $return; |
|
308 | + } |
|
309 | 309 | |
310 | - //-------------------------------------------------------------------- |
|
310 | + //-------------------------------------------------------------------- |
|
311 | 311 | |
312 | 312 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | if (! empty($model) ) |
25 | 25 | { |
26 | - $index_method = <<<EOD |
|
26 | + $index_method = <<<EOD |
|
27 | 27 | \$this->load->library('table'); |
28 | 28 | |
29 | 29 | \$offset = \$this->uri->segment( \$this->uri->total_segments() ); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | if (! empty($model)) |
46 | 46 | { |
47 | - $create_method = <<<EOD |
|
47 | + $create_method = <<<EOD |
|
48 | 48 | \$this->load->helper('form'); |
49 | 49 | \$this->load->helper('inflector'); |
50 | 50 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | if (! empty($model)) |
74 | 74 | { |
75 | - $show_method = <<<EOD |
|
75 | + $show_method = <<<EOD |
|
76 | 76 | \$item = \$this->{$lower_model}->find(\$id); |
77 | 77 | |
78 | 78 | if (! \$item) |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | if (! empty($model)) |
96 | 96 | { |
97 | - $update_method = <<<EOD |
|
97 | + $update_method = <<<EOD |
|
98 | 98 | \$this->load->helper('form'); |
99 | 99 | \$this->load->helper('inflector'); |
100 | 100 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | if (! empty($model)) |
127 | 127 | { |
128 | - $delete_method = <<<EOD |
|
128 | + $delete_method = <<<EOD |
|
129 | 129 | if (\$this->{$lower_model}->delete(\$id)) |
130 | 130 | { |
131 | 131 | \$this->setMessage('Successfully deleted item.', 'success'); |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | |
146 | 146 | if ($themed) |
147 | 147 | { |
148 | - $index_method .= "\$this->render();"; |
|
149 | - $create_method .= "\$this->render();"; |
|
150 | - $show_method .= "\$this->render();"; |
|
151 | - $update_method .= "\$this->render();"; |
|
148 | + $index_method .= "\$this->render();"; |
|
149 | + $create_method .= "\$this->render();"; |
|
150 | + $show_method .= "\$this->render();"; |
|
151 | + $update_method .= "\$this->render();"; |
|
152 | 152 | |
153 | - $fields = " |
|
153 | + $fields = " |
|
154 | 154 | /** |
155 | 155 | * Allows per-controller override of theme. |
156 | 156 | * @var null |
@@ -31,7 +31,7 @@ |
||
31 | 31 | */ |
32 | 32 | |
33 | 33 | $descriptions = [ |
34 | - 'controller' => ['controller <name> [<base>]', 'Creates a new controller file that extends from <base> or BaseController.'] |
|
34 | + 'controller' => ['controller <name> [<base>]', 'Creates a new controller file that extends from <base> or BaseController.'] |
|
35 | 35 | ]; |
36 | 36 | |
37 | 37 | $long_description = <<<EOT |
@@ -4,43 +4,43 @@ |
||
4 | 4 | |
5 | 5 | <?= $uikit->row([], function() use($uikit, $fields) { |
6 | 6 | |
7 | - $sizes = [ |
|
8 | - 's' => 12, |
|
9 | - 'm' => 6, |
|
10 | - 'l' => 4 |
|
11 | - ]; |
|
12 | - echo $uikit->column(['sizes' => $sizes], function() use($uikit, $fields) { |
|
13 | - |
|
14 | - foreach ($fields as $field) |
|
15 | - { |
|
16 | - echo $uikit->inputWrap( humanize($field['name']), null, function() use($uikit, $field) { |
|
17 | - |
|
18 | - switch ($field['type']) |
|
19 | - { |
|
20 | - case 'text': |
|
21 | - echo " <input type='text' class='form-control' name='{$field['name']}' />\n"; |
|
22 | - break; |
|
23 | - case 'number': |
|
24 | - echo " <input type='number' class='form-control' name='{$field['name']}' />\n"; |
|
25 | - break; |
|
26 | - case 'date': |
|
27 | - echo " <input type='date' class='form-control' name='{$field['name']}' />\n"; |
|
28 | - break; |
|
29 | - case 'datetime': |
|
30 | - echo " <input type='datetime' class='form-control' name='{$field['name']}' />\n"; |
|
31 | - break; |
|
32 | - case 'time': |
|
33 | - echo " <input type='time' class='form-control' name='{$field['name']}' />\n"; |
|
34 | - break; |
|
35 | - case 'textarea': |
|
36 | - echo " <textarea name='{$field['name']}' class='form-control'></textarea>\n"; |
|
37 | - break; |
|
38 | - } |
|
39 | - |
|
40 | - } ); |
|
41 | - } |
|
42 | - |
|
43 | - }); |
|
7 | + $sizes = [ |
|
8 | + 's' => 12, |
|
9 | + 'm' => 6, |
|
10 | + 'l' => 4 |
|
11 | + ]; |
|
12 | + echo $uikit->column(['sizes' => $sizes], function() use($uikit, $fields) { |
|
13 | + |
|
14 | + foreach ($fields as $field) |
|
15 | + { |
|
16 | + echo $uikit->inputWrap( humanize($field['name']), null, function() use($uikit, $field) { |
|
17 | + |
|
18 | + switch ($field['type']) |
|
19 | + { |
|
20 | + case 'text': |
|
21 | + echo " <input type='text' class='form-control' name='{$field['name']}' />\n"; |
|
22 | + break; |
|
23 | + case 'number': |
|
24 | + echo " <input type='number' class='form-control' name='{$field['name']}' />\n"; |
|
25 | + break; |
|
26 | + case 'date': |
|
27 | + echo " <input type='date' class='form-control' name='{$field['name']}' />\n"; |
|
28 | + break; |
|
29 | + case 'datetime': |
|
30 | + echo " <input type='datetime' class='form-control' name='{$field['name']}' />\n"; |
|
31 | + break; |
|
32 | + case 'time': |
|
33 | + echo " <input type='time' class='form-control' name='{$field['name']}' />\n"; |
|
34 | + break; |
|
35 | + case 'textarea': |
|
36 | + echo " <textarea name='{$field['name']}' class='form-control'></textarea>\n"; |
|
37 | + break; |
|
38 | + } |
|
39 | + |
|
40 | + } ); |
|
41 | + } |
|
42 | + |
|
43 | + }); |
|
44 | 44 | |
45 | 45 | }); ?> |
46 | 46 |
@@ -12,21 +12,21 @@ discard block |
||
12 | 12 | */ |
13 | 13 | if ($action == 'create') |
14 | 14 | { |
15 | - $up = "\$fields = {$fields}; |
|
15 | + $up = "\$fields = {$fields}; |
|
16 | 16 | |
17 | 17 | \$this->dbforge->add_field(\$fields); |
18 | 18 | "; |
19 | 19 | |
20 | - if (! empty($primary_key)) |
|
21 | - { |
|
22 | - $up .= " \$this->dbforge->add_key('{$primary_key}', true); |
|
20 | + if (! empty($primary_key)) |
|
21 | + { |
|
22 | + $up .= " \$this->dbforge->add_key('{$primary_key}', true); |
|
23 | 23 | "; |
24 | - } |
|
24 | + } |
|
25 | 25 | |
26 | - $up .=" \$this->dbforge->create_table('{$table}', true, config_item('migration_create_table_attr') ); |
|
26 | + $up .=" \$this->dbforge->create_table('{$table}', true, config_item('migration_create_table_attr') ); |
|
27 | 27 | "; |
28 | 28 | |
29 | - $down = "\$this->dbforge->drop_table('{$table}');"; |
|
29 | + $down = "\$this->dbforge->drop_table('{$table}');"; |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | /* |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | */ |
35 | 35 | if ($action == 'add' && ! empty($column)) |
36 | 36 | { |
37 | - $up = "\$field = {$column_string}; |
|
37 | + $up = "\$field = {$column_string}; |
|
38 | 38 | \$this->dbforge->add_column('{$table}', \$field);"; |
39 | 39 | |
40 | - $down = "\$this->dbforge->drop_column('{$table}', '{$column}');"; |
|
40 | + $down = "\$this->dbforge->drop_column('{$table}', '{$column}');"; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /* |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | */ |
46 | 46 | if ($action == 'remove' && ! empty($column)) |
47 | 47 | { |
48 | - $up = "\$this->dbforge->drop_column('{$table}', '{$column}');"; |
|
48 | + $up = "\$this->dbforge->drop_column('{$table}', '{$column}');"; |
|
49 | 49 | |
50 | - $down = "\$field = {$column_string}; |
|
50 | + $down = "\$field = {$column_string}; |
|
51 | 51 | \$this->dbforge->add_column('{$table}', \$field);"; |
52 | 52 | } |
53 | 53 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | { |
61 | 61 | $name = array_shift( $segments ); |
62 | 62 | |
63 | - $options = CLI::getOptions(); |
|
63 | + $options = CLI::getOptions(); |
|
64 | 64 | |
65 | 65 | $this->options['table_name'] = array_shift( $segments ); |
66 | 66 | |
@@ -213,17 +213,17 @@ discard block |
||
213 | 213 | // Check whether the table exists in this database |
214 | 214 | if ( ! $this->db->table_exists( $table_name ) ) |
215 | 215 | { |
216 | - if (empty($options['fields'])) |
|
217 | - { |
|
218 | - return FALSE; |
|
219 | - } |
|
216 | + if (empty($options['fields'])) |
|
217 | + { |
|
218 | + return FALSE; |
|
219 | + } |
|
220 | 220 | |
221 | - $fields = $this->parseFieldString($options['fields']); |
|
221 | + $fields = $this->parseFieldString($options['fields']); |
|
222 | + } |
|
223 | + else |
|
224 | + { |
|
225 | + $fields = $this->db->field_data( $table_name ); |
|
222 | 226 | } |
223 | - else |
|
224 | - { |
|
225 | - $fields = $this->db->field_data( $table_name ); |
|
226 | - } |
|
227 | 227 | |
228 | 228 | // There may be something wrong or the database driver may not return |
229 | 229 | // field data |
@@ -232,9 +232,9 @@ discard block |
||
232 | 232 | return FALSE; |
233 | 233 | } |
234 | 234 | |
235 | - $this->options['set_created'] = false; |
|
236 | - $this->options['set_modified'] = false; |
|
237 | - $this->options['use_soft_deletes'] = false; |
|
235 | + $this->options['set_created'] = false; |
|
236 | + $this->options['set_modified'] = false; |
|
237 | + $this->options['use_soft_deletes'] = false; |
|
238 | 238 | |
239 | 239 | // Use the primary key if the table has one already set. |
240 | 240 | foreach ( $fields as $field ) |
@@ -244,20 +244,20 @@ discard block |
||
244 | 244 | $this->options['primary_key'] = $field->name; |
245 | 245 | } |
246 | 246 | |
247 | - if ($field->name == $this->options['created_field']) |
|
248 | - { |
|
249 | - $this->options['set_created'] = true; |
|
250 | - } |
|
247 | + if ($field->name == $this->options['created_field']) |
|
248 | + { |
|
249 | + $this->options['set_created'] = true; |
|
250 | + } |
|
251 | 251 | |
252 | - if ($field->name == $this->options['modified_field']) |
|
253 | - { |
|
254 | - $this->options['set_modified'] = true; |
|
255 | - } |
|
252 | + if ($field->name == $this->options['modified_field']) |
|
253 | + { |
|
254 | + $this->options['set_modified'] = true; |
|
255 | + } |
|
256 | 256 | |
257 | - if ($field->name == $this->options['soft_delete_key']) |
|
258 | - { |
|
259 | - $this->options['use_soft_deletes'] = true; |
|
260 | - } |
|
257 | + if ($field->name == $this->options['soft_delete_key']) |
|
258 | + { |
|
259 | + $this->options['use_soft_deletes'] = true; |
|
260 | + } |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | // Set our validation rules based on these fields |
@@ -268,73 +268,73 @@ discard block |
||
268 | 268 | |
269 | 269 | //-------------------------------------------------------------------- |
270 | 270 | |
271 | - /** |
|
272 | - * Grabs the fields from the CLI options and gets them ready for |
|
273 | - * use within the views. |
|
274 | - */ |
|
275 | - protected function parseFieldString($fields) |
|
276 | - { |
|
277 | - if ( empty( $fields ) ) |
|
278 | - { |
|
279 | - return NULL; |
|
280 | - } |
|
281 | - |
|
282 | - $fields = explode( ' ', $fields ); |
|
283 | - |
|
284 | - $new_fields = [ ]; |
|
285 | - |
|
286 | - foreach ( $fields as $field ) |
|
287 | - { |
|
288 | - $pop = [ NULL, NULL, NULL ]; |
|
289 | - list( $field, $type, $size ) = array_merge( explode( ':', $field ), $pop ); |
|
290 | - $type = strtolower( $type ); |
|
291 | - |
|
292 | - // Strings |
|
293 | - if (in_array($type, ['char', 'varchar', 'string'])) |
|
294 | - { |
|
295 | - $new_fields[] = [ |
|
296 | - 'name' => $field, |
|
297 | - 'type' => 'text' |
|
298 | - ]; |
|
299 | - } |
|
300 | - |
|
301 | - // Textarea |
|
302 | - else if ($type == 'text') |
|
303 | - { |
|
304 | - $new_fields[] = [ |
|
305 | - 'name' => $field, |
|
306 | - 'type' => 'textarea' |
|
307 | - ]; |
|
308 | - } |
|
309 | - |
|
310 | - // Number |
|
311 | - else if (in_array($type, ['tinyint', 'int', 'bigint', 'mediumint', 'float', 'double', 'number'])) |
|
312 | - { |
|
313 | - $new_fields[] = [ |
|
314 | - 'name' => $field, |
|
315 | - 'type' => 'number' |
|
316 | - ]; |
|
317 | - } |
|
318 | - |
|
319 | - // Date |
|
320 | - else if (in_array($type, ['date', 'datetime', 'time'])) |
|
321 | - { |
|
322 | - $new_fields[] = [ |
|
323 | - 'name' => $field, |
|
324 | - 'type' => $type |
|
325 | - ]; |
|
326 | - } |
|
327 | - } |
|
328 | - |
|
329 | - // Convert to objects |
|
330 | - array_walk($new_fields, function(&$item, $key) { |
|
331 | - $item = (object)$item; |
|
332 | - }); |
|
333 | - |
|
334 | - return $new_fields; |
|
335 | - } |
|
336 | - |
|
337 | - //-------------------------------------------------------------------- |
|
271 | + /** |
|
272 | + * Grabs the fields from the CLI options and gets them ready for |
|
273 | + * use within the views. |
|
274 | + */ |
|
275 | + protected function parseFieldString($fields) |
|
276 | + { |
|
277 | + if ( empty( $fields ) ) |
|
278 | + { |
|
279 | + return NULL; |
|
280 | + } |
|
281 | + |
|
282 | + $fields = explode( ' ', $fields ); |
|
283 | + |
|
284 | + $new_fields = [ ]; |
|
285 | + |
|
286 | + foreach ( $fields as $field ) |
|
287 | + { |
|
288 | + $pop = [ NULL, NULL, NULL ]; |
|
289 | + list( $field, $type, $size ) = array_merge( explode( ':', $field ), $pop ); |
|
290 | + $type = strtolower( $type ); |
|
291 | + |
|
292 | + // Strings |
|
293 | + if (in_array($type, ['char', 'varchar', 'string'])) |
|
294 | + { |
|
295 | + $new_fields[] = [ |
|
296 | + 'name' => $field, |
|
297 | + 'type' => 'text' |
|
298 | + ]; |
|
299 | + } |
|
300 | + |
|
301 | + // Textarea |
|
302 | + else if ($type == 'text') |
|
303 | + { |
|
304 | + $new_fields[] = [ |
|
305 | + 'name' => $field, |
|
306 | + 'type' => 'textarea' |
|
307 | + ]; |
|
308 | + } |
|
309 | + |
|
310 | + // Number |
|
311 | + else if (in_array($type, ['tinyint', 'int', 'bigint', 'mediumint', 'float', 'double', 'number'])) |
|
312 | + { |
|
313 | + $new_fields[] = [ |
|
314 | + 'name' => $field, |
|
315 | + 'type' => 'number' |
|
316 | + ]; |
|
317 | + } |
|
318 | + |
|
319 | + // Date |
|
320 | + else if (in_array($type, ['date', 'datetime', 'time'])) |
|
321 | + { |
|
322 | + $new_fields[] = [ |
|
323 | + 'name' => $field, |
|
324 | + 'type' => $type |
|
325 | + ]; |
|
326 | + } |
|
327 | + } |
|
328 | + |
|
329 | + // Convert to objects |
|
330 | + array_walk($new_fields, function(&$item, $key) { |
|
331 | + $item = (object)$item; |
|
332 | + }); |
|
333 | + |
|
334 | + return $new_fields; |
|
335 | + } |
|
336 | + |
|
337 | + //-------------------------------------------------------------------- |
|
338 | 338 | |
339 | 339 | |
340 | 340 | /** |
@@ -31,7 +31,7 @@ |
||
31 | 31 | */ |
32 | 32 | |
33 | 33 | $descriptions = [ |
34 | - 'model' => ['model <name>', 'Creates a new model file that extends from CIDbModel.'] |
|
34 | + 'model' => ['model <name>', 'Creates a new model file that extends from CIDbModel.'] |
|
35 | 35 | ]; |
36 | 36 | |
37 | 37 | $long_description = <<<EOT |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | protected $model_name = ''; |
40 | 40 | |
41 | - protected $table_exists = false; |
|
41 | + protected $table_exists = false; |
|
42 | 42 | |
43 | 43 | //-------------------------------------------------------------------- |
44 | 44 | |
@@ -46,32 +46,32 @@ discard block |
||
46 | 46 | { |
47 | 47 | $name = array_shift( $segments ); |
48 | 48 | |
49 | - // If a table already exists then we don't need a migration |
|
50 | - $this->load->database(); |
|
51 | - if ($this->db->table_exists($name)) |
|
52 | - { |
|
53 | - $this->table_exists = true; |
|
54 | - } |
|
49 | + // If a table already exists then we don't need a migration |
|
50 | + $this->load->database(); |
|
51 | + if ($this->db->table_exists($name)) |
|
52 | + { |
|
53 | + $this->table_exists = true; |
|
54 | + } |
|
55 | 55 | |
56 | 56 | // If we didn't attach any fields, then we |
57 | 57 | // need to generate the barebones here. |
58 | 58 | $this->fields = CLI::option('fields'); |
59 | 59 | |
60 | - // If we don't have any fields, and no model |
|
61 | - // exists, then we need to provide some default fields. |
|
62 | - if (empty($this->fields)) |
|
63 | - { |
|
64 | - if (! $this->table_exists) |
|
65 | - { |
|
66 | - $this->fields = "id:int id:id title:string created_on:datetime modified_on:datetime"; |
|
67 | - } |
|
68 | - } |
|
60 | + // If we don't have any fields, and no model |
|
61 | + // exists, then we need to provide some default fields. |
|
62 | + if (empty($this->fields)) |
|
63 | + { |
|
64 | + if (! $this->table_exists) |
|
65 | + { |
|
66 | + $this->fields = "id:int id:id title:string created_on:datetime modified_on:datetime"; |
|
67 | + } |
|
68 | + } |
|
69 | 69 | |
70 | 70 | // Perform the steps. |
71 | - if (! $this->table_exists) |
|
72 | - { |
|
73 | - $this->makeMigration( $name ); |
|
74 | - } |
|
71 | + if (! $this->table_exists) |
|
72 | + { |
|
73 | + $this->makeMigration( $name ); |
|
74 | + } |
|
75 | 75 | $this->makeSeed($name); |
76 | 76 | $this->makeModel($name); |
77 | 77 | $this->makeController($name); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | public function makeSeed($name) |
100 | 100 | { |
101 | - $this->generate("seed {$name}", null, true); |
|
101 | + $this->generate("seed {$name}", null, true); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | //-------------------------------------------------------------------- |
@@ -106,33 +106,33 @@ discard block |
||
106 | 106 | |
107 | 107 | public function makeModel($name) |
108 | 108 | { |
109 | - $this->load->helper('inflector'); |
|
109 | + $this->load->helper('inflector'); |
|
110 | 110 | |
111 | 111 | $name = singular($name); |
112 | 112 | $this->model_name = $name; |
113 | 113 | |
114 | - // If a table exists, we can build it from that |
|
115 | - if ($this->table_exists) |
|
116 | - { |
|
117 | - $this->generate( "model {$name}", "-table $name -primary_key id", TRUE ); |
|
118 | - } |
|
119 | - // Otherwise, we need to provide the fields to make the model out of. |
|
120 | - else |
|
121 | - { |
|
122 | - $this->generate( "model {$name}", "-fields '{$this->fields}'", TRUE ); |
|
123 | - } |
|
114 | + // If a table exists, we can build it from that |
|
115 | + if ($this->table_exists) |
|
116 | + { |
|
117 | + $this->generate( "model {$name}", "-table $name -primary_key id", TRUE ); |
|
118 | + } |
|
119 | + // Otherwise, we need to provide the fields to make the model out of. |
|
120 | + else |
|
121 | + { |
|
122 | + $this->generate( "model {$name}", "-fields '{$this->fields}'", TRUE ); |
|
123 | + } |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | //-------------------------------------------------------------------- |
127 | 127 | |
128 | 128 | public function makeController($name) |
129 | 129 | { |
130 | - $options = "-model {$this->model_name} -create_views"; |
|
130 | + $options = "-model {$this->model_name} -create_views"; |
|
131 | 131 | |
132 | - if (! empty($this->fields)) |
|
133 | - { |
|
134 | - $options .= " -fields '{$this->fields}'"; |
|
135 | - } |
|
132 | + if (! empty($this->fields)) |
|
133 | + { |
|
134 | + $options .= " -fields '{$this->fields}'"; |
|
135 | + } |
|
136 | 136 | |
137 | 137 | $this->generate("controller {$name}", $options, true); |
138 | 138 | } |
@@ -1914,7 +1914,7 @@ |
||
1914 | 1914 | * @param int unix timestamp |
1915 | 1915 | * @param bool |
1916 | 1916 | * @return string |
1917 | - */ |
|
1917 | + */ |
|
1918 | 1918 | public function iso8601_encode($time, $utc = FALSE) |
1919 | 1919 | { |
1920 | 1920 | return ($utc) ? strftime('%Y%m%dT%H:%i:%s', $time) : gmstrftime('%Y%m%dT%H:%i:%s', $time); |