diff options
author | 2010-02-14 18:13:07 +0000 | |
---|---|---|
committer | 2010-02-14 18:13:07 +0000 | |
commit | aabae445999af9844cd462d9ace6b088a2daa255 (patch) | |
tree | 3c124520d795c3c0ebb6c9c392b975b504dd22c2 /import.categories.php | |
parent | split changelog, manifest (diff) | |
download | znurt-org-backend-aabae445999af9844cd462d9ace6b088a2daa255.tar.gz znurt-org-backend-aabae445999af9844cd462d9ace6b088a2daa255.tar.bz2 znurt-org-backend-aabae445999af9844cd462d9ace6b088a2daa255.zip |
cleanup
git-svn-id: file:///var/svn/portage@87 3218660a-b0cf-4799-a991-8ddcc5b9e0f3
Diffstat (limited to 'import.categories.php')
-rw-r--r-- | import.categories.php | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/import.categories.php b/import.categories.php index d4dcd63..880fb8e 100644 --- a/import.categories.php +++ b/import.categories.php @@ -11,6 +11,15 @@ $table = 'category'; + $sql = "SELECT COUNT(1) FROM category;"; + $count = $db->getOne($sql); + + // If no categories, reset the sequence + if($count === "0") { + $sql = "ALTER SEQUENCE category_id_seq RESTART WITH 1;"; + $db->query($sql); + } + $arr = $tree->getCategories(); $arr_diff = importDiff($table, $arr); @@ -27,7 +36,25 @@ foreach($arr_diff['insert'] as $name) { $arr_insert = array('name' => $name); $db->autoExecute($table, $arr_insert, MDB2_AUTOQUERY_INSERT); + + $category_id = $db->lastInsertID(); + + $c = new PortageCategory($name); + + foreach($c->getDescriptions() as $lingua => $description) { + + $arr_insert = array( + 'category' => $category_id, + 'lingua' => $lingua, + 'description' => $description, + ); + + $db->autoExecute('category_description', $arr_insert, MDB2_AUTOQUERY_INSERT); + + } + } + } // FIXME I should check the mtimes of the directories @@ -40,14 +67,15 @@ $sql = "SELECT name, id FROM category;"; $arr = $db->getAssoc($sql); - foreach($arr as $category_name => $category) { - - $db_category = new DBCategory($category); - $c = new PortageCategory($category_name); - - if($db_category->description != $c->description['en']) - $db_category->description = $c->description['en']; - - } + // FIXME work with linguas +// foreach($arr as $category_name => $category) { +// +// $db_category = new DBCategory($category); +// $c = new PortageCategory($category_name); +// +// if($db_category->description != $c->description['en']) +// $db_category->description = $c->description['en']; +// +// } ?>
\ No newline at end of file |