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


PHP DBField::add_extra方法代碼示例

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


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


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