From 72eaeb9aedf14936ae7601ed0ac61c4014943129 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 1 Nov 2010 09:25:57 +0100 Subject: add TableAcls class ans use it in refresh --- class/CommonTable.php | 20 ++++++++++++++++ class/TableAcls.php | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 class/TableAcls.php (limited to 'class') diff --git a/class/CommonTable.php b/class/CommonTable.php index 0aeeb29..b7cc93e 100644 --- a/class/CommonTable.php +++ b/class/CommonTable.php @@ -306,6 +306,26 @@ abstract class CommonTable } return $tab; } + + /** + * Truncate the table + */ + public function truncate() + { + return $this->exec('TRUNCATE `'.$this->table.'`'); + } + + /** + * Get the number of rows in the table + */ + public function getCount() + { + $sql = 'SELECT COUNT(*) AS cpt FROM `'.$this->table.'`'; + foreach ($this->request($sql) as $row) { + return ($row['cpt']); + } + return 0; + } } ?> \ No newline at end of file diff --git a/class/TableAcls.php b/class/TableAcls.php new file mode 100644 index 0000000..bbf72a1 --- /dev/null +++ b/class/TableAcls.php @@ -0,0 +1,63 @@ +. + * + * @category Main + * @package RPMPHP + * + * @author Remi Collet + * @author Johan Cwiklinski + * @copyright 2010 Remi Collet + * @license http://www.gnu.org/licenses/agpl-3.0-standalone.html AGPL License 3.0 or (at your option) any later version + * @link http://github.com/remicollet/rpmphp/ + * @since The begining of times. +*/ +class TableAcls extends CommonTable +{ + /** + * Create the table and populate it with known repo + * + * @return void + */ + protected function createTable() + { + // Table schema + $sql = "CREATE TABLE IF NOT EXISTS `acls` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `collection` varchar(100) NOT NULL, + `name` varchar(100) NOT NULL, + `summary` varchar(200) NOT NULL, + `owner` varchar(50) DEFAULT NULL, + `qa` varchar(50) DEFAULT NULL, + `cc` varchar(100) DEFAULT NULL, + PRIMARY KEY (`id`), + KEY `name` (`name`), + KEY `collection` (`collection`), + KEY `owner` (`owner`) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8;"; + $this->exec($sql); + } +} +?> \ No newline at end of file -- cgit