當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DBUtil::truncateTable方法代碼示例

本文整理匯總了PHP中DBUtil::truncateTable方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBUtil::truncateTable方法的具體用法?PHP DBUtil::truncateTable怎麽用?PHP DBUtil::truncateTable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DBUtil的用法示例。


在下文中一共展示了DBUtil::truncateTable方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: mediashare_mediahandlerapi_scanMediaHandlers

function mediashare_mediahandlerapi_scanMediaHandlers()
{
    // Check access
    if (!SecurityUtil::checkPermission('mediashare::', '::', ACCESS_ADMIN)) {
        return LogUtil::registerPermissionError();
    }
    $dom = ZLanguage::getModuleDomain('mediashare');
    // Clear existing handler table
    if (!DBUtil::truncateTable('mediashare_mediahandlers')) {
        return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('mediahandlerapi.scanMediaHandlers', __f("Could not clear the '%s' table.", 'mediahandlers', $dom)), $dom));
    }
    // Scan for handlers APIs
    $files = FileUtil::getFiles('modules/mediashare', false, true, 'php', 'f');
    foreach ($files as $file) {
        if (preg_match('/^pnmedia_([-a-zA-Z0-9_]+)api.php$/', $file, $matches)) {
            $handlerName = $matches[1];
            $handlerApi = "media_{$handlerName}";
            // Force load - it is used during pninit
            pnModAPILoad('mediashare', $handlerApi, true);
            if (!($handler = pnModAPIFunc('mediashare', $handlerApi, 'buildHandler'))) {
                return false;
            }
            $fileTypes = $handler->getMediaTypes();
            foreach ($fileTypes as $fileType) {
                $fileType['handler'] = $handlerName;
                $fileType['title'] = $handler->getTitle();
                if (!pnModAPIFunc('mediashare', 'mediahandler', 'addMediaHandler', $fileType)) {
                    return false;
                }
            }
        }
    }
    return true;
}
開發者ID:ro0f,項目名稱:Mediashare,代碼行數:34,代碼來源:pnmediahandlerapi.php

示例2: mediashare_sourcesapi_scanSources

function mediashare_sourcesapi_scanSources()
{
    // Check access
    if (!SecurityUtil::checkPermission('mediashare::', '::', ACCESS_ADMIN)) {
        return LogUtil::registerPermissionError();
    }
    $dom = ZLanguage::getModuleDomain('mediashare');
    // Clear existing sources table
    if (!DBUtil::truncateTable('mediashare_sources')) {
        return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('sourcesapi.scanSources', __f("Could not clear the '%s' table.", 'sources', $dom)), $dom));
    }
    // Scan for sources APIs
    $files = FileUtil::getFiles('modules/mediashare', false, true, 'php', 'f');
    foreach ($files as $file) {
        if (preg_match('/^pnsource_([-a-zA-Z0-9_]+)api.php$/', $file, $matches)) {
            $sourceName = $matches[1];
            $sourceApi = "source_{$sourceName}";
            // Force load - it is used during pninit
            pnModAPILoad('mediashare', $sourceApi, true);
            if (!($title = pnModAPIFunc('mediashare', $sourceApi, 'getTitle'))) {
                return false;
            }
            if (!pnModAPIFunc('mediashare', 'sources', 'addSource', array('title' => $title, 'name' => $sourceName))) {
                return false;
            }
        }
    }
    return true;
}
開發者ID:ro0f,項目名稱:Mediashare,代碼行數:29,代碼來源:pnsourcesapi.php

示例3: resetPermissions

 public function resetPermissions()
 {
     // Delete all current permission entries.
     if (!DBUtil::truncateTable('group_perms')) {
         $this->setError(__('Error! Permission not deleted'));
         return false;
     }
     // Array of permission objects to insert.
     $perms = array();
     $perms[] = array('pid' => 1, 'gid' => 2, 'sequence' => 1, 'realm' => 0, 'component' => '.*', 'instance' => '.*', 'level' => 800, 'bond' => 0);
     $perms[] = array('pid' => 2, 'gid' => -1, 'sequence' => 2, 'realm' => 0, 'component' => 'ExtendedMenublock::', 'instance' => '1:2:', 'level' => 0, 'bond' => 0);
     $perms[] = array('pid' => 3, 'gid' => 1, 'sequence' => 3, 'realm' => 0, 'component' => '.*', 'instance' => '.*', 'level' => 300, 'bond' => 0);
     $perms[] = array('pid' => 4, 'gid' => 0, 'sequence' => 4, 'realm' => 0, 'component' => 'ExtendedMenublock::', 'instance' => '1:(1|3):', 'level' => 0, 'bond' => 0);
     $perms[] = array('pid' => 5, 'gid' => 0, 'sequence' => 5, 'realm' => 0, 'component' => '.*', 'instance' => '.*', 'level' => 200, 'bond' => 0);
     // Insert default permissions or fail.
     if (!DBUtil::insertObjectArray($perms, 'group_perms', 'pid')) {
         $this->setError(__('Error inserting permission'));
         return false;
     }
     // Success.
     return true;
 }
開發者ID:Silwereth,項目名稱:core,代碼行數:22,代碼來源:zrc.php


注:本文中的DBUtil::truncateTable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。