@@ -268,6 +268,7 @@ public function add_key($key, $primary = FALSE)
268
268
*
269
269
* @param array $field
270
270
* @return CI_DB_forge
271
+ * @throws RuntimeException if field information is not specified
271
272
*/
272
273
public function add_field ($ field )
273
274
{
@@ -288,7 +289,7 @@ public function add_field($field)
288
289
{
289
290
if (strpos ($ field , ' ' ) === FALSE )
290
291
{
291
- show_error ('Field information is required for that operation. ' );
292
+ throw new RuntimeException ('Field information is required for that operation. ' );
292
293
}
293
294
294
295
$ this ->fields [] = $ field ;
@@ -312,12 +313,13 @@ public function add_field($field)
312
313
* @param bool $if_not_exists Whether to add IF NOT EXISTS condition
313
314
* @param array $attributes Associative array of table attributes
314
315
* @return bool
316
+ * @throws RuntimeException if table name or field information is not specified
315
317
*/
316
318
public function create_table ($ table , $ if_not_exists = FALSE , array $ attributes = array ())
317
319
{
318
320
if ($ table === '' )
319
321
{
320
- show_error ('A table name is required for that operation. ' );
322
+ throw new RuntimeException ('A table name is required for that operation. ' );
321
323
}
322
324
else
323
325
{
@@ -326,7 +328,7 @@ public function create_table($table, $if_not_exists = FALSE, array $attributes =
326
328
327
329
if (count ($ this ->fields ) === 0 )
328
330
{
329
- show_error ('Field information is required. ' );
331
+ throw new RuntimeException ('Field information is required. ' );
330
332
}
331
333
332
334
$ sql = $ this ->_create_table ($ table , $ if_not_exists , $ attributes );
@@ -514,12 +516,13 @@ protected function _drop_table($table, $if_exists)
514
516
* @param string $table_name Old table name
515
517
* @param string $new_table_name New table name
516
518
* @return bool
519
+ * @throws RuntimeException if table name is not specified
517
520
*/
518
521
public function rename_table ($ table_name , $ new_table_name )
519
522
{
520
523
if ($ table_name === '' OR $ new_table_name === '' )
521
524
{
522
- show_error ('A table name is required for that operation. ' );
525
+ throw new RuntimeException ('A table name is required for that operation. ' );
523
526
return FALSE ;
524
527
}
525
528
elseif ($ this ->_rename_table === FALSE )
@@ -617,6 +620,7 @@ public function drop_column($table, $column_name)
617
620
* @param string $table Table name
618
621
* @param string $field Column definition
619
622
* @return bool
623
+ * @throws RuntimeExceptions if field information is not specified
620
624
*/
621
625
public function modify_column ($ table , $ field )
622
626
{
@@ -630,7 +634,7 @@ public function modify_column($table, $field)
630
634
631
635
if (count ($ this ->fields ) === 0 )
632
636
{
633
- show_error ('Field information is required. ' );
637
+ throw new RuntimeException ('Field information is required. ' );
634
638
}
635
639
636
640
$ sqls = $ this ->_alter_table ('CHANGE ' , $ this ->db ->dbprefix .$ table , $ this ->_process_fields ());
0 commit comments