本文整理汇总了PHP中PHPWS_DB::resetValues方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPWS_DB::resetValues方法的具体用法?PHP PHPWS_DB::resetValues怎么用?PHP PHPWS_DB::resetValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPWS_DB
的用法示例。
在下文中一共展示了PHPWS_DB::resetValues方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save($item_id, $table, $total_backups = 5)
{
if (!PHPWS_DB::isTable($table)) {
return FALSE;
}
$backupTable = Backup::getBackupTable($table);
if (PHPWS_Error::isError($backupTable)) {
return $backupTable;
}
$db = new PHPWS_DB($table);
$db->addWhere('id', $item_id);
$source_row = $db->select('row');
$db2 = new PHPWS_DB($backupTable);
$db2->addWhere('backup_id', $source_row['id']);
$db2->addOrder('backup_order');
$past_rows = $db2->select();
$past_row_count = count($past_rows);
if (empty($past_rows) || $past_row_count < $total_backups) {
$db2->reset();
$source_row['backup_id'] = $source_row['id'];
unset($source_row['id']);
$source_row['backup_order'] = $past_row_count + 1;
$db2->addValue($source_row);
$result = $db2->insert();
} else {
$db2->delete();
$db2->reset();
unset($past_rows[0]);
$source_row['backup_id'] = $source_row['id'];
unset($source_row['id']);
$past_rows[] = $source_row;
foreach ($past_rows as $key => $row) {
$row['backup_order'] = $key;
$db2->addValue($row);
$db2->insert();
$db2->resetValues();
}
}
}
示例2: savePermissions
public function savePermissions()
{
if (!$this->id) {
return false;
}
$db = new PHPWS_DB('phpws_key');
$db->addValue('restricted', $this->restricted);
if (PHPWS_Error::logIfError($db->saveObject($this))) {
return false;
}
$view_db = new PHPWS_DB('phpws_key_view');
$view_db->addWhere('key_id', $this->id);
$result = $view_db->delete();
if (PHPWS_Error::isError($result)) {
return $result;
}
$edit_db = new PHPWS_DB('phpws_key_edit');
$edit_db->addWhere('key_id', $this->id);
$result = $edit_db->delete();
if (PHPWS_Error::isError($result)) {
return $result;
}
// we don't care if restricted is 0 because everyone can view
// we don't care if it is KEY_LOGGED_RESTRICTED either because
// just checking log status covers it
if ($this->restricted == KEY_GROUP_RESTRICTED) {
if (!empty($this->_view_groups) && is_array($this->_view_groups)) {
$view_db->reset();
$this->_view_groups = array_unique($this->_view_groups);
foreach ($this->_view_groups as $group_id) {
$view_db->resetValues();
$view_db->addValue('key_id', $this->id);
$view_db->addValue('group_id', $group_id);
PHPWS_Error::logIfError($view_db->insert());
}
}
}
if (!empty($this->_edit_groups) && is_array($this->_edit_groups)) {
$edit_db->reset();
$this->_edit_groups = array_unique($this->_edit_groups);
foreach ($this->_edit_groups as $group_id) {
$edit_db->resetValues();
$edit_db->addValue('key_id', $this->id);
$edit_db->addValue('group_id', $group_id);
PHPWS_Error::logIfError($edit_db->insert());
}
}
return true;
}
示例3: save
public function save()
{
$db = new PHPWS_DB('users_groups');
$result = $db->saveObject($this);
$members = $this->getMembers();
if (isset($members)) {
$this->dropAllMembers();
$db = new PHPWS_DB('users_members');
foreach ($members as $member) {
$db->addValue('group_id', $this->getId());
$db->addValue('member_id', $member);
PHPWS_Error::logIfError($db->insert());
$db->resetValues();
}
}
}