summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--class/TablePackagist.php58
-rw-r--r--testdb.php30
2 files changed, 87 insertions, 1 deletions
diff --git a/class/TablePackagist.php b/class/TablePackagist.php
new file mode 100644
index 0000000..74cc9ea
--- /dev/null
+++ b/class/TablePackagist.php
@@ -0,0 +1,58 @@
+<?php
+
+/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
+
+/**
+ * Class for "packagist" Table management
+ *
+ * PHP version 5
+ *
+ * Copyright © 2014 Remi Collet
+ *
+ * This file is part of rpmphp.
+ *
+ * rpmphp is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * rpmphp is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with rpmphp. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * @category Main
+ * @package RPMPHP
+ *
+ * @author Remi Collet <unknown@unknwown.com>
+ * @author Johan Cwiklinski <johan@x-tnd.be>
+ * @copyright 2014 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 TablePackagist extends CommonTable
+{
+ /**
+ * Create the table and populate it with known repo
+ *
+ * @return void
+ */
+ protected function createTable()
+ {
+ // Table schema
+ $sql = "CREATE TABLE IF NOT EXISTS `packagist` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `pkgname` varchar(100) NOT NULL,
+ `rpmname` varchar(200) NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `pkgname` (`pkgname`),
+ UNIQUE KEY `rpmname` (`rpmname`)
+ ) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
+ $this->exec($sql);
+ }
+
+}
diff --git a/testdb.php b/testdb.php
index 263a0c9..4ee4879 100644
--- a/testdb.php
+++ b/testdb.php
@@ -105,4 +105,32 @@ echo "PECL owner:";
print_r($acl->getOwners('php-pecl-%'));
echo "PEAR channels:";
print_r($up->getChannels('pear'));
-?>
+
+$pkg = new TablePackagist($db);
+$nb = $pkg->getCount();
+echo "Pkgs number : $nb\n";
+if ($nb) {
+ $i=0;
+ foreach($pkg->request(array('ORDER'=>'rpmname')) as $rec) {
+ printf("%3d %-30s %s\n", $rec['id'], $rec['pkgname'], $rec['rpmname']);
+ if ($i++ > 10) {
+ echo ("...etc...\n");
+ break;
+ }
+ }
+/*
+} else {
+ $f = '/home/rpmbuild/SPECS/remirepo/tools/checkpkgist/checkpkgist.json';
+ $f = file_get_contents($f);
+ $pkgs = json_decode($f, true, 5, JSON_PARSER_NOTSTRICT);
+ foreach ($pkgs as $p => $q) {
+ $data = array(
+ 'pkgname' => $p,
+ 'rpmname' => $q,
+ );
+ $pkg->add($data);
+ }
+ $nb = $pkg->getCount();
+ echo "Pkgs number : $nb\n";
+*/
+}