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


PHP DBField::set_default方法代碼示例

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


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

示例1: DBField

<?php

//upgrade from v1.2 to v1.3 (DB 2 -> 3)
//add new config values
set_config('date_format', 'd M Y');
set_config('time_format', 'H:i');
set_config('bbcode_privatemsg', 1);
echo '<li>RV3: Adding new config values... success</li>';
//update database structure
$db->drop_field('users', 'dst');
$new_timezone = new DBField('timezone', 'INT(3)');
$new_timezone->set_default(0);
$db->alter_field('users', $new_timezone);
$archived_fld = new DBField('archived', 'TINYINT(1)');
$archived_fld->add_extra('NOT NULL');
$archived_fld->set_default(0);
$db->add_field('forums', $archived_fld, 'num_posts');
echo '<li>RV3: Updating database structure... success</li>';
//convert all old timezones (just the UTC offset) to the new technique which uses the entire PHP dictionary
//map all UTC offsets to new timezones
$mappings = array(-12 => 383, -11 => 398, -10 => 53, -9 => 94, -8 => 132, -7 => 162, -6 => 144, -5 => 151, -4 => 84, -3 => 57, -2 => 295, -1 => 8, 0 => 415, 1 => 333, 2 => 327, 3 => 340, 4 => 230, 5 => 244, 6 => 266, 7 => 220, 8 => 271, 9 => 279, 10 => 309, 11 => 399, 12 => 385, 13 => 213);
//I hate mass queries as much as anyone, but they have to be done
foreach ($mappings as $oldtime => $newtime) {
    $db->query('UPDATE `#^users` SET timezone=' . $newtime . ' WHERE timezone=' . $oldtime) or enhanced_error('Failed to update timezone', true);
}
echo '<li>RV3: Converting timezones... success</li>';
ExtensionConfig::add_page('/styles', array('file' => 'style.php', 'template' => false, 'admin' => false, 'mod' => false, 'subdirs' => true));
ExtensionConfig::remove_page('/styles/default.css');
ExtensionConfig::remove_page('/styles/default.css/');
ExtensionConfig::remove_page('/styles/embed.css');
echo '<li>RV3: Adding missing pages... success</li>';
開發者ID:Cythral,項目名稱:futurebb,代碼行數:31,代碼來源:3.php

示例2: DBField

$new_fld->add_extra('NOT NULL');
$tables['interface_history']->add_field($new_fld);
$new_fld = new DBField('field', 'VARCHAR(50)');
$new_fld->add_extra('NOT NULL');
$new_fld->set_default('\'\'');
$new_fld->set_default('\'\'');
$tables['interface_history']->add_field($new_fld);
$new_fld = new DBField('user', 'INT');
$new_fld->add_extra('NOT NULL');
$tables['interface_history']->add_field($new_fld);
$new_fld = new DBField('time', 'INT');
$new_fld->add_extra('NOT NULL');
$tables['interface_history']->add_field($new_fld);
$new_fld = new DBField('old_value', 'TEXT');
$new_fld->add_extra('NOT NULL');
$new_fld->set_default('\'\'');
$new_fld->set_default('\'\'');
$tables['interface_history']->add_field($new_fld);
$tables['interface_history']->commit();
echo '<li>RV2: Adding interface history table... success</li>';
//run through stock cache to insert pages and language keys
include FORUM_ROOT . '/app_config/cache/pages.php';
$q = 'INSERT INTO `#^pages`(url,file,template,nocontentbox,admin,moderator,subdirs) VALUES';
$page_insert_data = array();
$orig_pages = $pages;
$orig_pagessubdirs = $pagessubdirs;
include FORUM_ROOT . '/app_config/pages.php';
$pages = array_merge($pages, $orig_pages);
foreach ($pages as $url => $info) {
    $page_insert_data[] = '(\'' . $db->escape($url) . '\',\'' . $db->escape($info['file']) . '\',' . ($info['template'] ? '1' : '0') . ',' . (isset($info['nocontentbox']) ? '1' : '0') . ',' . (isset($info['admin']) && $info['admin'] ? '1' : '0') . ',' . (isset($info['mod']) && $info['mod'] ? '1' : '0') . ',0)';
}
開發者ID:Cythral,項目名稱:futurebb,代碼行數:31,代碼來源:2.php

示例3: array

ExtensionConfig::add_page('/myimages', array('file' => 'myimages.php', 'template' => true));
set_config('user_image_maxwidth', 1024);
set_config('user_image_maxheight', 768);
set_config('user_image_maxsize', 512);
$table = new DBTable('userimages');
$new_fld = new DBField('id', 'INT');
$new_fld->add_key('PRIMARY');
$new_fld->add_extra('NOT NULL');
$new_fld->add_extra('AUTO_INCREMENT');
$table->add_field($new_fld);
$new_fld = new DBField('filename', 'VARCHAR(256)');
$new_fld->add_extra('NOT NULL');
$table->add_field($new_fld);
$new_fld = new DBField('user', 'INT');
$new_fld->add_extra('NOT NULL');
$table->add_field($new_fld);
$new_fld = new DBField('ip_addr', 'VARCHAR(50)');
$new_fld->add_extra('NOT NULL');
$table->add_field($new_fld);
$new_fld = new DBField('time', 'INT');
$new_fld->add_extra('NOT NULL');
$table->add_field($new_fld);
$new_fld = new DBField('extension', 'VARCHAR(10)');
$new_fld->add_extra('NOT NULL');
$table->add_field($new_fld);
$table->commit();
$new_fld = new DBField('g_upload_images', 'TINYINT(1)');
$new_fld->add_extra('NOT NULL');
$new_fld->set_default(0);
$db->add_field('user_groups', $new_fld, 'g_post_images');
$db->query('UPDATE `#^user_groups` SET g_upload_images=1 WHERE g_permanent=1') or enhanced_error('Failed to update user groups', true);
開發者ID:futuresight,項目名稱:futurebb-image-uploading-extension,代碼行數:31,代碼來源:database.php

示例4: DBField

 $tables['user_groups']->add_field($new_fld);
 $new_fld = new DBField('g_access_board', 'TINYINT(1)');
 $new_fld->add_extra('NOT NULL');
 $new_fld->set_default('1');
 $tables['user_groups']->add_field($new_fld);
 $new_fld = new DBField('g_view_forums', 'TINYINT(1)');
 $new_fld->add_extra('NOT NULL');
 $new_fld->set_default('1');
 $tables['user_groups']->add_field($new_fld);
 $new_fld = new DBField('g_post_topics', 'TINYINT(1)');
 $new_fld->add_extra('NOT NULL');
 $new_fld->set_default('1');
 $tables['user_groups']->add_field($new_fld);
 $new_fld = new DBField('g_post_replies', 'TINYINT(1)');
 $new_fld->add_extra('NOT NULL');
 $new_fld->set_default('1');
 $tables['user_groups']->add_field($new_fld);
 $tables['user_groups']->commit();
 unset($tables);
 unset($new_fld);
 //add database data
 set_config('board_title', get_cookie_data('board_title'));
 set_config('announcement_text', '');
 set_config('announcement_enable', 0);
 set_config('online_timeout', 300);
 set_config('show_post_count', 1);
 set_config('sig_max_length', 0);
 set_config('sig_max_lines', 0);
 set_config('sig_max_height', 0);
 set_config('default_language', 'English');
 set_config('default_user_group', 3);
開發者ID:Cythral,項目名稱:futurebb,代碼行數:31,代碼來源:install.php


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