getAssoc($sql); $sql = "SELECT category, package, category_name, package_name FROM view_package;"; $arr = $db->getAll($sql); foreach($arr as $row) { $arr_package_ids[$row['category_name']][$row['package_name']] = $row['package']; } $table = 'package'; foreach($arr_categories as $category_id => $category_name) { $obj_category = new PortageCategory($category_name); $arr_packages = $obj_category->getPackages(); $arr_diff = importDiff('package', $arr_packages, "category = $category_id"); if(count($arr_diff['delete'])) { foreach($arr_diff['delete'] as $name) { $sql = "DELETE FROM $table WHERE name = ".$db->quote($name)." AND category = $category_id;"; $db->query($sql); } } if(count($arr_diff['insert'])) { foreach($arr_diff['insert'] as $package_name) { $obj_package = new PortagePackage($obj_category->name, $package_name); $arr_insert = array('category' => $category_id, 'name' => $package_name, 'changelog' => $obj_package->changelog); $db->autoExecute($table, $arr_insert, MDB2_AUTOQUERY_INSERT); } } foreach($arr_packages as $package_name) { if(!in_array($package_name, $arr_diff['insert'])) { $package_id = $arr_package_ids[$category_name][$package_name]; if($package_id) { // if($verbose) { // shell::msg("Updating $category_name/$package_name id: $package_id"); // } $db_package = new DBPackage($package_id); $p = new PortagePackage($obj_category->name, $package_name); if($p->mtime != $db_package->mtime) $db_package->mtime = $p->mtime; if($p->ctime != $db_package->ctime) $db_package->ctime = $p->ctime; if($p->changelog != $db_package->changelog) $db_package->changelog = $p->changelog; } } } } ?>