本文整理汇总了PHP中PackageList::selectPackage方法的典型用法代码示例。如果您正苦于以下问题:PHP PackageList::selectPackage方法的具体用法?PHP PackageList::selectPackage怎么用?PHP PackageList::selectPackage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PackageList
的用法示例。
在下文中一共展示了PackageList::selectPackage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: reg_set_packages
function reg_set_packages()
{
global $xoopsDB;
$active = get_active_list();
$pkgs = get_packages('all');
if (file_exists(ROLLBACK)) {
unlink(ROLLBACK);
}
// expired
$del = "DELETE FROM " . UPDATE_PKG . " WHERE pkgid=%u";
$sel = "SELECT pkgid FROM " . UPDATE_PKG . " WHERE vcheck=%s AND pversion='HEAD'";
$succ = 0;
$pnames = isset($_POST['pname']) ? $_POST['pname'] : array();
foreach ($pkgs as $pkg) {
$dirname = $pkg['vcheck'];
if (array_search($dirname, $active)) {
$res = $xoopsDB->query(sprintf($sel, $xoopsDB->quoteString($dirname)));
$pkgid = 0;
if ($xoopsDB->getRowsNum($res) > 0) {
list($pkgid) = $xoopsDB->fetchRow($res);
}
$pname = $pkg['pname'];
if ($pkgid && !in_array($dirname, $pnames)) {
// unchecked? (removed)
if ($xoopsDB->query(sprintf($del, $pkgid))) {
$xoopsDB->query("DELETE FROM " . UPDATE_FILE . " WHERE pkgref={$pkgid}");
$succ++;
}
}
clean_pkginfo();
// garbege collection
}
}
$ins = "INSERT INTO " . UPDATE_PKG . "(parent,pname,pversion,vcheck) VALUES(%u,%s,'HEAD',%s)";
foreach ($pnames as $dirname) {
if (!in_array($dirname, $active)) {
if (isset($pkgs[$dirname])) {
$pkg = $pkgs[$dirname];
} else {
$pkg = PackageList::selectPackage($dirname);
}
$par = empty($pkg['pkgid']) ? 0 : $pkg['pkgid'];
if (register_detail($pkg['pname'], $dirname)) {
$succ++;
}
}
}
if ($succ) {
clear_get_cache(0, 'list');
}
return $succ;
}