当前位置: 首页>>代码示例>>PHP>>正文


PHP DBUtil::selectScalar方法代码示例

本文整理汇总了PHP中DBUtil::selectScalar方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtil::selectScalar方法的具体用法?PHP DBUtil::selectScalar怎么用?PHP DBUtil::selectScalar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBUtil的用法示例。


在下文中一共展示了DBUtil::selectScalar方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: contentGetNextRevisionNumber

 protected function contentGetNextRevisionNumber($pageId)
 {
     $pageId = (int) $pageId;
     $tables = DBUtil::getTables();
     $historyTable = $tables['content_history'];
     $historyColumn = $tables['content_history_column'];
     $sql = "\n            SELECT MAX({$historyColumn['revisionNo']})\n            FROM {$historyTable}\n            WHERE {$historyColumn['pageId']} = {$pageId}";
     // FIXME: how to avoid concurrency problems?
     $pos = DBUtil::selectScalar($sql);
     return $pos === null ? 1 : (int) $pos + 1;
 }
开发者ID:robbrandt,项目名称:Content,代码行数:11,代码来源:History.php

示例2: contentGetLastContentPosition

 protected function contentGetLastContentPosition($pageId, $contentAreaIndex)
 {
     $pageId = (int) $pageId;
     $contentAreaIndex = (int) $contentAreaIndex;
     $table = DBUtil::getTables();
     $contentTable = $table['content_content'];
     $contentColumn = $table['content_content_column'];
     $sql = "\n            SELECT MAX({$contentColumn['position']})\n            FROM {$contentTable}\n            WHERE {$contentColumn['pageId']} = {$pageId}";
     $pos = DBUtil::selectScalar($sql);
     return $pos === null ? -1 : (int) $pos;
 }
开发者ID:robbrandt,项目名称:Content,代码行数:11,代码来源:Content.php

示例3: insertPage

    public function insertPage($args)
    {
        $pageId = (int) $args['pageId'];
        $position = (int) $args['position'];
        $parentPageId = (int) $args['parentPageId'];

        $dbtables = DBUtil::getTables();
        $pageTable = $dbtables['content_page'];
        $pageColumn = $dbtables['content_page_column'];

        $sql = "
            UPDATE $pageTable
            SET $pageColumn[position] = $pageColumn[position]+1
            WHERE $pageColumn[parentPageId] = $parentPageId
            AND $pageColumn[position] >= $position";

        DBUtil::executeSQL($sql);

        // *** Update all left/right values for all pages "right of this page"
        // Assume "this page" has left/right values that matches it's subtree (but with a wrong offset)
        $pageData = DBUtil::selectObjectByID('content_page', $pageId);
        if ($parentPageId > 0) {
            $parentPageData = DBUtil::selectObjectByID('content_page', $parentPageId);
            $parentLevel = $parentPageData['level'];
        } else {
            $parentPageData = null;
            $parentLevel = -1;
        }

        // Fetch largest left/right value left of this page's new position
        $sql = "
            SELECT MAX($pageColumn[setRight])
            FROM $pageTable
            WHERE $pageColumn[parentPageId] = $parentPageId
            AND $pageColumn[position] < $position
            AND $pageColumn[id] != $pageId";

        $maxLeftOfthis = DBUtil::selectScalar($sql);
        if (empty($maxLeftOfthis)) {
            $maxLeftOfthis = -1;
        }
        if ($parentPageData != null && $parentPageData['setLeft'] > $maxLeftOfthis) {
            $maxLeftOfthis = $parentPageData['setLeft'];
        }
        $diff = $pageData['setRight'] - $pageData['setLeft'] + 1;
        $sql = "
            UPDATE $pageTable SET
            $pageColumn[setRight] = $pageColumn[setRight]+$diff
            WHERE $pageColumn[setRight] > $maxLeftOfthis AND $pageColumn[id] != $pageId";

        DBUtil::executeSQL($sql);

        $sql = "
            UPDATE $pageTable SET
            $pageColumn[setLeft] = $pageColumn[setLeft]+$diff
            WHERE $pageColumn[setLeft] > $maxLeftOfthis AND $pageColumn[id] != $pageId";

        DBUtil::executeSQL($sql);

        // *** Update level/left/right values for this page and all pages below
        $levelDiff = $pageData['level'] - ($parentLevel + 1);
        $diff2 = $pageData['setLeft'] - $maxLeftOfthis - 1;
        //echo "diff2=$diff2. ";
        $sql = "
            UPDATE $pageTable SET
            $pageColumn[setLeft] = $pageColumn[setLeft]-$diff2,
            $pageColumn[setRight] = $pageColumn[setRight]-$diff2,
            $pageColumn[level] = $pageColumn[level]-$levelDiff
            WHERE $pageData[setLeft] <= $pageColumn[setLeft] AND $pageColumn[setRight] <= $pageData[setRight]";

        DBUtil::executeSQL($sql);

        // Update this page
        $newPageData = array('id' => $pageId, 'position' => $position, 'parentPageId' => $parentPageId, 'level' => ($parentPageData == null ? 0 : $parentPageData['level'] + 1));
        DBUtil::updateObject($newPageData, 'content_page');

        return true;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:78,代码来源:Page.php

示例4: contentGetLastContentPosition

    protected function contentGetLastContentPosition($pageId, $contentAreaIndex)
    {
        $pageId = (int) $pageId;
        $contentAreaIndex = (int) $contentAreaIndex;

        $table = DBUtil::getTables();
        $contentTable = $table['content_content'];
        $contentColumn = $table['content_content_column'];

        $sql = "
            SELECT MAX($contentColumn[position])
            FROM $contentTable
            WHERE $contentColumn[pageId] = $pageId";

        $pos = DBUtil::selectScalar($sql);
        return $pos === null ? -1 : (int) $pos;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:17,代码来源:Content.php

示例5: insertPage

 public function insertPage($args)
 {
     $pageId = (int) $args['pageId'];
     $position = (int) $args['position'];
     $parentPageId = (int) $args['parentPageId'];
     $dbtables = DBUtil::getTables();
     $pageTable = $dbtables['content_page'];
     $pageColumn = $dbtables['content_page_column'];
     $sql = "\n            UPDATE {$pageTable}\n            SET {$pageColumn['position']} = {$pageColumn['position']}+1\n            WHERE {$pageColumn['parentPageId']} = {$parentPageId}\n            AND {$pageColumn['position']} >= {$position}";
     DBUtil::executeSQL($sql);
     // *** Update all left/right values for all pages "right of this page"
     // Assume "this page" has left/right values that matches it's subtree (but with a wrong offset)
     $pageData = DBUtil::selectObjectByID('content_page', $pageId);
     if ($parentPageId > 0) {
         $parentPageData = DBUtil::selectObjectByID('content_page', $parentPageId);
         $parentLevel = $parentPageData['level'];
     } else {
         $parentPageData = null;
         $parentLevel = -1;
     }
     // Fetch largest left/right value left of this page's new position
     $sql = "\n            SELECT MAX({$pageColumn['setRight']})\n            FROM {$pageTable}\n            WHERE {$pageColumn['parentPageId']} = {$parentPageId}\n            AND {$pageColumn['position']} < {$position}\n            AND {$pageColumn['id']} != {$pageId}";
     $maxLeftOfthis = DBUtil::selectScalar($sql);
     if (empty($maxLeftOfthis)) {
         $maxLeftOfthis = -1;
     }
     if ($parentPageData != null && $parentPageData['setLeft'] > $maxLeftOfthis) {
         $maxLeftOfthis = $parentPageData['setLeft'];
     }
     $diff = $pageData['setRight'] - $pageData['setLeft'] + 1;
     $sql = "\n            UPDATE {$pageTable} SET\n            {$pageColumn['setRight']} = {$pageColumn['setRight']}+{$diff}\n            WHERE {$pageColumn['setRight']} > {$maxLeftOfthis} AND {$pageColumn['id']} != {$pageId}";
     DBUtil::executeSQL($sql);
     $sql = "\n            UPDATE {$pageTable} SET\n            {$pageColumn['setLeft']} = {$pageColumn['setLeft']}+{$diff}\n            WHERE {$pageColumn['setLeft']} > {$maxLeftOfthis} AND {$pageColumn['id']} != {$pageId}";
     DBUtil::executeSQL($sql);
     // *** Update level/left/right values for this page and all pages below
     $levelDiff = $pageData['level'] - ($parentLevel + 1);
     $diff2 = $pageData['setLeft'] - $maxLeftOfthis - 1;
     //echo "diff2=$diff2. ";
     $sql = "\n            UPDATE {$pageTable} SET\n            {$pageColumn['setLeft']} = {$pageColumn['setLeft']}-{$diff2},\n            {$pageColumn['setRight']} = {$pageColumn['setRight']}-{$diff2},\n            {$pageColumn['level']} = {$pageColumn['level']}-{$levelDiff}\n            WHERE {$pageData['setLeft']} <= {$pageColumn['setLeft']} AND {$pageColumn['setRight']} <= {$pageData['setRight']}";
     DBUtil::executeSQL($sql);
     // Update this page
     $newPageData = array('id' => $pageId, 'position' => $position, 'parentPageId' => $parentPageId, 'level' => $parentPageData == null ? 0 : $parentPageData['level'] + 1);
     DBUtil::updateObject($newPageData, 'content_page');
     return true;
 }
开发者ID:robbrandt,项目名称:Content,代码行数:45,代码来源:Page.php


注:本文中的DBUtil::selectScalar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。