本文整理汇总了PHP中RoleModel::Save方法的典型用法代码示例。如果您正苦于以下问题:PHP RoleModel::Save方法的具体用法?PHP RoleModel::Save怎么用?PHP RoleModel::Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RoleModel
的用法示例。
在下文中一共展示了RoleModel::Save方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: OldIndex
public function OldIndex($Step = 0)
{
$this->Permission('Garden.Data.Import');
// This permission doesn't exist, so only users with Admin == '1' will succeed.
$this->AddJsFile('upgrade.js', 'vanilla');
$Step = is_numeric($Step) && $Step >= 0 && $Step < 20 ? $Step : '';
$Database = Gdn::Database();
$Construct = $Database->Structure();
$PDO = $Database->Connection();
$SourcePrefix = Gdn::Config('Garden.Import.SourcePrefix', 'LUM_');
$DestPrefix = Gdn::Config('Database.DatabasePrefix', '');
if ($Step == 0) {
$this->View = 'import';
if ($this->Form->AuthenticatedPostBack()) {
// Make sure that all of the destination tables exist (assuming that
// columns are there if tables are there since they were likely just
// installed moments ago).
$DbTables = $Database->SQL()->FetchTables();
$DestTables = explode(',', 'Role,User,UserRole,Conversation,ConversationMessage,UserConversation,Category,Discussion,Comment,UserDiscussion');
for ($i = 0; $i < count($DestTables); ++$i) {
$Table = $DestPrefix . $DestTables[$i];
if (!InArrayI($Table, $DbTables)) {
$this->Form->AddError('The "' . $Table . '" table is required for import.');
break;
}
}
if ($this->Form->ErrorCount() == 0) {
// Make sure that all of the source tables & columns exist.
$SourcePrefix = $this->Form->GetFormValue('SourcePrefix');
$SourceTables = explode(',', 'Role,User,UserRoleHistory,UserDiscussionWatch,UserBookmark,Category,Discussion,Comment');
for ($i = 0; $i < count($SourceTables); ++$i) {
$Table = $SourcePrefix . $SourceTables[$i];
if (!InArrayI($Table, $DbTables)) {
$this->Form->AddError('The "' . $Table . '" source table was not found. Are you sure "' . $SourcePrefix . '" is the correct table prefix for your Vanilla 1 tables?');
break;
}
$Columns = $Database->SQL()->FetchColumns($Table);
switch ($SourceTables[$i]) {
case 'Role':
$RequiredColumns = explode(',', 'RoleID,Name,Description');
break;
case 'User':
$RequiredColumns = explode(',', 'UserID,RoleID,Name,Email,UtilizeEmail,CountVisit,Discovery,DateFirstVisit,DateLastActive,DateFirstVisit,DateLastActive,CountDiscussions,CountComments');
break;
case 'UserRoleHistory':
$RequiredColumns = explode(',', 'UserID,RoleID,AdminUserID,Notes,Date');
break;
case 'UserDiscussionWatch':
$RequiredColumns = explode(',', 'UserID,DiscussionID,CountComments,LastViewed');
break;
case 'UserBookmark':
$RequiredColumns = explode(',', 'UserID,DiscussionID');
break;
case 'Category':
$RequiredColumns = explode(',', 'CategoryID,Name,Description,Priority');
break;
case 'Discussion':
$RequiredColumns = explode(',', 'DiscussionID,CategoryID,AuthUserID,LastUserID,WhisperUserID,Active,Name,CountComments,Closed,Sticky,Sink,DateCreated,DateLastActive');
break;
case 'Comment':
$RequiredColumns = explode(',', 'CommentID,DiscussionID,AuthUserID,EditUserID,WhisperUserID,Deleted,Body,FormatType,DateCreated,DateEdited');
break;
default:
$RequiredColumns = array();
break;
}
if (is_array($RequiredColumns)) {
for ($j = 0; $j < count($RequiredColumns); ++$j) {
if (!InArrayI($RequiredColumns[$j], $Columns)) {
$this->Form->AddError('The "' . $Table . '" source table does not have the "' . $RequiredColumns[$j] . '" column.');
break;
}
}
}
}
}
// If there were no errors...
if ($this->Form->ErrorCount() == 0) {
// Save the sourceprefix
SaveToConfig('Garden.Import.SourcePrefix', $SourcePrefix);
// Proceed with the next step
$this->Message = T('<strong>1/19</strong> Checking source & destination tables.');
$this->View = 'index';
$this->RedirectUrl = Url('/upgrade/1');
if ($this->DeliveryType() == DELIVERY_TYPE_ALL) {
Redirect('/upgrade/1');
}
}
}
} else {
if ($Step == 1) {
// 1. Add Import IDs to various tables where necessary
$Construct->Table('Role')->Column('ImportID', 'int', TRUE, 'key')->Set();
$Construct->Table('User')->Column('ImportID', 'int', TRUE, 'key')->Set();
$Construct->Table('Category')->Column('ImportID', 'int', TRUE, 'key')->Set();
$Construct->Table('Discussion')->Column('ImportID', 'int', TRUE, 'key')->Set();
$Construct->DatabasePrefix($SourcePrefix);
$Construct->Table('Comment')->Column('ConversationID', 'int', TRUE, 'key')->Set();
$Construct->DatabasePrefix($DestPrefix);
$this->Message = T('<strong>2/19</strong> Preparing tables for import.');
//.........这里部分代码省略.........