本文整理汇总了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;
}
示例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;
}
示例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;
}