From db257c7de11da2771a9f61733f21a42c98cf2a97 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 1 Nov 2010 18:40:08 +0100 Subject: add CommonTable->optimize() method and call it during refresh --- class/CommonTable.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'class/CommonTable.php') diff --git a/class/CommonTable.php b/class/CommonTable.php index b7cc93e..365ef19 100644 --- a/class/CommonTable.php +++ b/class/CommonTable.php @@ -84,7 +84,9 @@ abstract class CommonTable $res = $this->db->exec($sql); if ($res===false) { $err = $this->db->errorInfo(); - throw new Exception("\nSQL: $sql\nERROR: ".$err[2]."\nCODE:"); + throw new Exception( + "\nSQL: $sql\nERROR: " . $err[2] . "\nCODE:" . $err[0] + ); } return $res; } @@ -315,6 +317,19 @@ abstract class CommonTable return $this->exec('TRUNCATE `'.$this->table.'`'); } + /** + * Optimize the table + */ + public function optimize() + { + $res = array(); + foreach ($this->request('OPTIMIZE TABLE `'.$this->table.'`') as $row) { + $res[] = $row; + } + return $res; + } + + /** * Get the number of rows in the table */ -- cgit