Skip to content

Commit

Permalink
Table: cleanup columns() after testing.
Browse files Browse the repository at this point in the history
This change fixes the return value of columns() so that it returns $results instead of true on success.

See fe6e235.

See #111.
  • Loading branch information
JJJ committed May 28, 2021
1 parent 0c870f1 commit 550ad19
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions table.php
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,10 @@ public function columns() {
$query = "SHOW FULL COLUMNS FROM {$this->table_name}";
$result = $db->get_results( $query );

// Does the table have columns?
return $this->is_success( $result );
// Return the results
return $this->is_success( $result )
? $result
: false;
}

/**
Expand Down Expand Up @@ -468,11 +470,11 @@ public function delete_all() {
}

// Query statement
$query = "DELETE FROM {$this->table_name}";
$deleted = $db->query( $query );
$query = "DELETE FROM {$this->table_name}";
$result = $db->query( $query );

// Did the table get emptied?
return $deleted;
// Return the results
return $result;
}

/**
Expand Down Expand Up @@ -569,11 +571,11 @@ public function count() {
}

// Query statement
$query = "SELECT COUNT(*) FROM {$this->table_name}";
$count = $db->get_var( $query );
$query = "SELECT COUNT(*) FROM {$this->table_name}";
$result = $db->get_var( $query );

// Query success/fail
return intval( $count );
return intval( $result );
}

/**
Expand Down

0 comments on commit 550ad19

Please sign in to comment.