Пример #1
0
function addLinkCategory($blogid, $categoryTitle)
{
    $pool = DBModel::getInstance();
    $pool->init("LinkCategories");
    $pool->setQualifier("blogid", "eq", $blogid);
    $pool->setQualifier("name", "eq", $categoryTitle, true);
    $id = $pool->getCell();
    if (!empty($id)) {
        return $id;
    } else {
        // Add new Link Category
        $pid = getMaxPidOfLinkCategory() + 1;
        $id = getMaxIdOfLinkCategory($blogid) + 1;
        $priority = 0;
        $visibility = 2;
        // Default visibility
        $pool->init("LinkCategories");
        $pool->setAttribute("pid", $pid);
        $pool->setAttribute("blogid", $blogid);
        $pool->setAttribute("id", $id);
        $pool->setAttribute("name", $categoryTitle, true);
        $pool->setAttribute("priority", $priority);
        $pool->setAttribute("visibility", $visibility);
        if ($pool->insert()) {
            return $id;
        } else {
            return false;
        }
    }
}
Пример #2
0
function addLinkCategory($blogid, $categoryTitle)
{
    global $database;
    $categoryTitle = POD::escapeString($categoryTitle);
    $id = POD::queryCell("SELECT id FROM {$database['prefix']}LinkCategories\n\t\tWHERE blogid = {$blogid} AND name = '" . $categoryTitle . "'");
    if (!empty($id)) {
        return $id;
    } else {
        // Add new Link Category
        $pid = getMaxPidOfLinkCategory() + 1;
        $id = getMaxIdOfLinkCategory($blogid) + 1;
        $priority = 0;
        $visibility = 2;
        // Default visibility
        if (POD::query("INSERT INTO {$database['prefix']}LinkCategories\n\t\t\t(pid, blogid, id, name, priority, visibility) VALUES\n\t\t\t({$pid}, {$blogid}, {$id}, '{$categoryTitle}', {$priority}, {$visibility})")) {
            return $id;
        } else {
            return false;
        }
    }
}