本文整理匯總了PHP中Gdn_Model::Save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Gdn_Model::Save方法的具體用法?PHP Gdn_Model::Save怎麽用?PHP Gdn_Model::Save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Gdn_Model
的用法示例。
在下文中一共展示了Gdn_Model::Save方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Save
public function Save($FormPostValues, $Settings = FALSE)
{
// Get the ID of an existing tag with the same name.
$ExistingTag = $this->GetWhere(array('Name' => $FormPostValues['Name'], 'TagID <>' => GetValue('TagID', $FormPostValues)))->FirstRow(DATASET_TYPE_ARRAY);
if ($ExistingTag) {
if (!GetValue('TagID', $FormPostValues)) {
return $ExistingTag['TagID'];
}
// This tag will be merged with the existing one.
$Px = $this->Database->DatabasePrefix;
$FromID = $FormPostValues['TagID'];
$ToID = $ExistingTag['TagID'];
try {
$this->Database->BeginTransaction();
// Delete all of the overlapping tags.
$Sql = "delete tg.*\n from {$Px}TagDiscussion tg\n join {$Px}TagDiscussion tg2\n on tg.DiscussionID = tg2.DiscussionID\n and tg.TagID = :FromID and tg2.TagID = :ToID";
$this->Database->Query($Sql, array(':FromID' => $FromID, ':ToID' => $ToID));
// Update the tagged discussions.
$Sql = "update {$Px}TagDiscussion\n set TagID = :ToID\n where TagID = :FromID";
$this->Database->Query($Sql, array(':FromID' => $FromID, ':ToID' => $ToID));
// Update the counts.
$Sql = "update {$Px}Tag t\n set CountDiscussions = (\n select count(DiscussionID)\n from {$Px}TagDiscussion td\n where td.TagID = t.TagID)\n where t.TagID = :ToID";
$this->Database->Query($Sql, array(':ToID' => $ToID));
// Delete the old tag.
$Sql = "delete from {$Px}Tag where TagID = :FromID";
$this->Database->Query($Sql, array(':FromID' => $FromID));
$this->Database->CommitTransaction();
} catch (Exception $Ex) {
$this->Database->RollbackTransaction();
throw $Ex;
}
} else {
parent::Save($FormPostValues, $Settings);
}
}
示例2: Save
public function Save($PostValues, $PreviousValues = False)
{
ReplaceEmpty($PostValues, Null);
$URI = GetValue('URI', $PostValues, Null);
$bCreateSection = GetValue('CreateSection', $PostValues);
$RowID = GetValue('PageID', $PostValues);
$Insert = $RowID === False;
if ($bCreateSection) {
$SectionModel = Gdn::Factory('SectionModel');
$this->Validation->ApplyRule('URI', 'UrlPath');
$this->Validation->ApplyRule('SectionID', 'Required');
if ($Insert && $URI && CandyModel::GetRoute($URI)) {
$this->Validation->AddValidationResult('URI', '%s: Already exists.');
}
}
$this->EventArguments['PostValues'] =& $PostValues;
$this->FireEvent('BeforeSave');
$RowID = parent::Save($PostValues);
if ($RowID) {
if ($URI) {
CandyModel::SaveRoute($URI, 'candy/content/page/' . $RowID);
}
if ($bCreateSection) {
$this->CreateSection($RowID, $PostValues);
}
}
return $RowID;
}
示例3: Save
public function Save($PostValues, $EditingData = False)
{
ReplaceEmpty($PostValues, Null);
$Insert = GetValue('ChunkID', $PostValues) === False;
if ($Insert) {
$this->AddUpdateFields($PostValues);
}
$RowID = parent::Save($PostValues);
return $RowID;
}
示例4: Save
public function Save($FormPostValues, $Settings = FALSE)
{
// The "location" is packed into a single input with a / delimiter. Need to explode it into three different fields for saving
$Location = ArrayValue('Location', $FormPostValues, '');
if ($Location != '') {
$Location = explode('/', $Location);
$Application = GetValue(0, $Location, '');
if (in_array($Application, $this->_SpecialLocations)) {
$FormPostValues['Application'] = NULL;
$FormPostValues['Controller'] = $Application;
$FormPostValues['Method'] = NULL;
} else {
$FormPostValues['Application'] = $Application;
$FormPostValues['Controller'] = GetValue(1, $Location, '');
$FormPostValues['Method'] = GetValue(2, $Location, '');
}
}
Gdn::Cache()->Remove('Messages');
return parent::Save($FormPostValues, $Settings);
}
示例5: Save
/**
* Save data about ban from form.
*
* @since 2.0.18
* @access public
*
* @param array $FormPostValues
* @param array $Settings
*/
public function Save($FormPostValues, $Settings = FALSE)
{
$CurrentBanID = GetValue('BanID', $FormPostValues);
// Get the current ban before saving.
if ($CurrentBanID) {
$CurrentBan = $this->GetID($CurrentBanID, DATASET_TYPE_ARRAY);
} else {
$CurrentBan = NULL;
}
$this->SetCounts($FormPostValues);
$BanID = parent::Save($FormPostValues, $Settings);
$FormPostValues['BanID'] = $BanID;
$this->ApplyBan($FormPostValues, $CurrentBan);
}
示例6: MergeStart
protected function MergeStart($OldUserID, $NewUserID)
{
$Model = new Gdn_Model('UserMerge');
// Grab the users.
$OldUser = $this->GetID($OldUserID, DATASET_TYPE_ARRAY);
$NewUser = $this->GetID($NewUserID, DATASET_TYPE_ARRAY);
// First see if there is a record with the same merge.
$Row = $Model->GetWhere(array('OldUserID' => $OldUserID, 'NewUserID' => $NewUserID))->FirstRow(DATASET_TYPE_ARRAY);
if ($Row) {
$MergeID = $Row['MergeID'];
// Save this merge in the log.
if ($Row['Attributes']) {
$Attributes = unserialize($Row['Attributes']);
} else {
$Attributes = array();
}
$Attributes['Log'][] = array('UserID' => Gdn::Session()->UserID, 'Date' => Gdn_Format::ToDateTime());
$Row = array('MergeID' => $MergeID, 'Attributes' => $Attributes);
} else {
$Row = array('OldUserID' => $OldUserID, 'NewUserID' => $NewUserID);
}
$UserSet = array();
$OldUserSet = array();
if (DateCompare($OldUser['DateFirstVisit'], $NewUser['DateFirstVisit']) < 0) {
$UserSet['DateFirstVisit'] = $OldUser['DateFirstVisit'];
}
if (!isset($Row['Attributes']['User']['CountVisits'])) {
$UserSet['CountVisits'] = $OldUser['CountVisits'] + $NewUser['CountVisits'];
$OldUserSet['CountVisits'] = 0;
}
if (!empty($UserSet)) {
// Save the user information on the merge record.
foreach ($UserSet as $Key => $Value) {
// Only save changed values that aren't already there from a previous merge.
if ($NewUser[$Key] != $Value && !isset($Row['Attributes']['User'][$Key])) {
$Row['Attributes']['User'][$Key] = $NewUser[$Key];
}
}
}
$MergeID = $Model->Save($Row);
if (GetValue('MergeID', $Row)) {
$MergeID = $Row['MergeID'];
}
if (!$MergeID) {
throw new Gdn_UserException($Model->Validation->ResultsText());
}
// Update the user with the new user-level data.
$this->SetField($NewUserID, $UserSet);
if (!empty($OldUserSet)) {
$this->SetField($OldUserID, $OldUserSet);
}
return $MergeID;
}
示例7: Save
public function Save($FormPostValues, $Settings = FALSE)
{
// The "location" is packed into a single input with a / delimiter. Need to explode it into three different fields for saving
$Location = ArrayValue('Location', $FormPostValues, '');
if ($Location != '') {
$Location = explode('/', $Location);
if ($Location[0] == 'Base') {
$FormPostValues['Controller'] = 'Base';
} else {
if (count($Location) >= 1) {
$FormPostValues['Application'] = $Location[0];
}
if (count($Location) >= 2) {
$FormPostValues['Controller'] = $Location[1];
}
if (count($Location) >= 3) {
$FormPostValues['Method'] = $Location[2];
}
}
}
// Make sure that messages on the dashboard get dropped below the page heading.
if ($FormPostValues['Application'] == 'Garden' && $FormPostValues['Controller'] == 'Settings' && $FormPostValues['Method'] == 'Index') {
$FormPostValues['AssetTarget'] = 'Messages';
}
return parent::Save($FormPostValues, $Settings);
}
示例8: Save
public function Save($FormPostValues, $Settings = FALSE)
{
// The "location" is packed into a single input with a / delimiter. Need to explode it into three different fields for saving
$Location = ArrayValue('Location', $FormPostValues, '');
if ($Location != '') {
$Location = explode('/', $Location);
if ($Location[0] == 'Base') {
$FormPostValues['Controller'] = 'Base';
} else {
if (count($Location) >= 1) {
$FormPostValues['Application'] = $Location[0];
}
if (count($Location) >= 2) {
$FormPostValues['Controller'] = $Location[1];
}
if (count($Location) >= 3) {
$FormPostValues['Method'] = $Location[2];
}
}
}
return parent::Save($FormPostValues, $Settings);
}
示例9: save
/**
* Save data about ban from form.
*
* @since 2.0.18
* @access public
*
* @param array $FormPostValues
* @param array $Settings
*/
public function save($FormPostValues, $Settings = false)
{
$CurrentBanID = val('BanID', $FormPostValues);
// Get the current ban before saving.
if ($CurrentBanID) {
$CurrentBan = $this->getID($CurrentBanID, DATASET_TYPE_ARRAY);
} else {
$CurrentBan = null;
}
$this->SetCounts($FormPostValues);
$BanID = parent::Save($FormPostValues, $Settings);
$FormPostValues['BanID'] = $BanID;
$this->EventArguments['CurrentBan'] = $CurrentBan;
$this->EventArguments['FormPostValues'] = $FormPostValues;
$this->fireEvent('AfterSave');
$this->ApplyBan($FormPostValues, $CurrentBan);
}
示例10: Save
public function Save($Fields, $Settings = False)
{
self::SetNullValues($Fields);
$RowID = parent::Save($Fields, $Settings);
return $RowID;
}
示例11: Touch
public static function Touch($Name, $Value)
{
$Model = new Gdn_Model('Pocket');
$Pockets = $Model->GetWhere(array('Name' => $Name))->ResultArray();
if (empty($Pockets)) {
$Pocket = array('Name' => $Name, 'Location' => 'Content', 'Sort' => 0, 'Repeat' => Pocket::REPEAT_BEFORE, 'Body' => $Value, 'Format' => 'Raw', 'Disabled' => Pocket::DISABLED, 'MobileOnly' => 0, 'MobileNever' => 0, 'EmbeddedNever' => 0, 'ShowInDashboard' => 0, 'Type' => 'default');
$Model->Save($Pocket);
}
}