From 550ad1993bcebe096b813c18db014fe6d8461390 Mon Sep 17 00:00:00 2001 From: John James Jacoby Date: Fri, 28 May 2021 00:26:34 -0500 Subject: [PATCH] Table: cleanup columns() after testing. This change fixes the return value of columns() so that it returns $results instead of true on success. See fe6e2355be7dac36950bfeef8f0b7a098eb34ca2. See #111. --- table.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/table.php b/table.php index a66e03c..df5e748 100644 --- a/table.php +++ b/table.php @@ -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; } /** @@ -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; } /** @@ -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 ); } /**