Skip to content

Commit 9439f87

Browse files
author
David Otis
committed
bcit-ci#4189 removed show_error from database/DB_forge
1 parent 2eacf4c commit 9439f87

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

system/database/DB_forge.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ public function add_key($key, $primary = FALSE)
268268
*
269269
* @param array $field
270270
* @return CI_DB_forge
271+
* @throws RuntimeException if field information is not specified
271272
*/
272273
public function add_field($field)
273274
{
@@ -288,7 +289,7 @@ public function add_field($field)
288289
{
289290
if (strpos($field, ' ') === FALSE)
290291
{
291-
show_error('Field information is required for that operation.');
292+
throw new RuntimeException('Field information is required for that operation.');
292293
}
293294

294295
$this->fields[] = $field;
@@ -312,12 +313,13 @@ public function add_field($field)
312313
* @param bool $if_not_exists Whether to add IF NOT EXISTS condition
313314
* @param array $attributes Associative array of table attributes
314315
* @return bool
316+
* @throws RuntimeException if table name or field information is not specified
315317
*/
316318
public function create_table($table, $if_not_exists = FALSE, array $attributes = array())
317319
{
318320
if ($table === '')
319321
{
320-
show_error('A table name is required for that operation.');
322+
throw new RuntimeException('A table name is required for that operation.');
321323
}
322324
else
323325
{
@@ -326,7 +328,7 @@ public function create_table($table, $if_not_exists = FALSE, array $attributes =
326328

327329
if (count($this->fields) === 0)
328330
{
329-
show_error('Field information is required.');
331+
throw new RuntimeException('Field information is required.');
330332
}
331333

332334
$sql = $this->_create_table($table, $if_not_exists, $attributes);
@@ -514,12 +516,13 @@ protected function _drop_table($table, $if_exists)
514516
* @param string $table_name Old table name
515517
* @param string $new_table_name New table name
516518
* @return bool
519+
* @throws RuntimeException if table name is not specified
517520
*/
518521
public function rename_table($table_name, $new_table_name)
519522
{
520523
if ($table_name === '' OR $new_table_name === '')
521524
{
522-
show_error('A table name is required for that operation.');
525+
throw new RuntimeException('A table name is required for that operation.');
523526
return FALSE;
524527
}
525528
elseif ($this->_rename_table === FALSE)
@@ -617,6 +620,7 @@ public function drop_column($table, $column_name)
617620
* @param string $table Table name
618621
* @param string $field Column definition
619622
* @return bool
623+
* @throws RuntimeExceptions if field information is not specified
620624
*/
621625
public function modify_column($table, $field)
622626
{
@@ -630,7 +634,7 @@ public function modify_column($table, $field)
630634

631635
if (count($this->fields) === 0)
632636
{
633-
show_error('Field information is required.');
637+
throw new RuntimeException('Field information is required.');
634638
}
635639

636640
$sqls = $this->_alter_table('CHANGE', $this->db->dbprefix.$table, $this->_process_fields());

user_guide_src/source/database/forge.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ Class Reference
335335
:param array $field: Field definition to add
336336
:returns: CI_DB_forge instance (method chaining)
337337
:rtype: CI_DB_forge
338+
:throws: RuntimeException if field information is not specified
338339

339340
Adds a field to the set that will be used to create a table. Usage: See `Adding fields`_.
340341

@@ -362,6 +363,7 @@ Class Reference
362363
:param string $attributes: An associative array of table attributes
363364
:returns: TRUE on success, FALSE on failure
364365
:rtype: bool
366+
:throws: RuntimeException if table name or field information is not specified
365367

366368
Creates a new table. Usage: See `Creating a table`_.
367369

@@ -397,6 +399,7 @@ Class Reference
397399
:param array $field: Column definition(s)
398400
:returns: TRUE on success, FALSE on failure
399401
:rtype: bool
402+
:throws: RuntimeException if field information is not specified
400403

401404
Modifies a table column. Usage: See `Modifying a Column in a Table`_.
402405

@@ -406,5 +409,6 @@ Class Reference
406409
:param string $new_table_name: New name of the table
407410
:returns: TRUE on success, FALSE on failure
408411
:rtype: bool
412+
:throws: RuntimeException if table name is not specified
409413

410414
Renames a table. Usage: See `Renaming a table`_.

0 commit comments

Comments
 (0)