本文整理汇总了PHP中PHPWS_DB::update方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPWS_DB::update方法的具体用法?PHP PHPWS_DB::update怎么用?PHP PHPWS_DB::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPWS_DB
的用法示例。
在下文中一共展示了PHPWS_DB::update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save()
{
$result = parent::save();
if (PHPWS_Error::isError($result)) {
return $result;
}
$db = new PHPWS_DB('analytics_tracker_owa');
$db->addWhere('id', $this->id);
$result = $db->select();
if (PHPWS_Error::logIfError($result)) {
return $result;
}
$db = new PHPWS_DB('analytics_tracker_owa');
$db->addValue('id', $this->id);
$db->addValue('owa_url', $this->owa_url);
$db->addValue('owa_site_id', $this->owa_site_id);
$db->addValue('owa_track_page_view', $this->owa_track_page_view);
$db->addValue('owa_track_clicks', $this->owa_track_clicks);
$db->addValue('owa_track_domstream', $this->owa_track_domstream);
if (count($result) < 1) {
$result = $db->insert(false);
} else {
$result = $db->update();
}
if (PHPWS_Error::logIfError($result)) {
return $result;
}
}
示例2: saveObject
public static function saveObject(DbStorable $o)
{
$vars = $o->extractVars();
$tableName = $o::getTableName();
// Check if the key already exists
$query = "SELECT * FROM {$tableName} WHERE id = {$vars['id']}";
$result = \PHPWS_DB::getAll($query);
if (count($result) > 0) {
$exists = true;
} else {
$exists = false;
}
$db = new \PHPWS_DB($o->getTableName());
foreach ($vars as $key => $value) {
$db->addValue($key, $value);
}
if ($exists) {
$db->addWhere('id', $vars['id']);
$result = $db->update();
} else {
$result = $db->insert(false);
}
if (\PHPWS_Error::logIfError($result)) {
throw new \Exception($result->toString());
}
}
示例3: save
public function save()
{
$result = parent::save();
if (PHPWS_Error::isError($result)) {
return $result;
}
$db = new PHPWS_DB('analytics_tracker_piwik');
$db->addWhere('id', $this->id);
$result = $db->select();
if (PHPWS_Error::logIfError($result)) {
return $result;
}
$db = new PHPWS_DB('analytics_tracker_piwik');
$db->addValue('id', $this->id);
$db->addValue('piwik_url', $this->piwik_url);
$db->addValue('piwik_id', $this->piwik_id);
if (count($result) < 1) {
$result = $db->insert(false);
} else {
$result = $db->update();
}
if (PHPWS_Error::logIfError($result)) {
return $result;
}
}
示例4: menu_unregister_key
/**
* unregisters deleted keys from menu
*
* @author Matthew McNaney <mcnaney at gmail dot com>
* @version $Id$
*/
function menu_unregister_key(Key $key)
{
PHPWS_Core::initModClass('menu', 'Menu_Link.php');
if (empty($key) || empty($key->id)) {
return FALSE;
}
$db = new PHPWS_DB('menu_links');
$db->addWhere('key_id', $key->id);
$result = $db->delete();
if (PHPWS_Error::isError($result)) {
PHPWS_Error::log($result);
}
$db2 = new PHPWS_DB('menu_assoc');
$db2->addWhere('key_id', $key->id);
$result = $db2->delete();
if (PHPWS_Error::isError($result)) {
PHPWS_Error::log($result);
}
$db3 = new PHPWS_DB('menus');
$db3->addWhere('assoc_key', $key->id);
$db3->addValue('assoc_key', 0);
$db3->addValue('assoc_url', null);
$db3->update();
return true;
}
示例5: filecabinet_unregister
/**
* @version $Id$
* @author Matthew McNaney <mcnaney at gmail dot com>
*/
function filecabinet_unregister($module, &$content)
{
$db = new PHPWS_DB('folders');
$db->addValue('module_created', null);
$db->addWhere('module_created', $module);
PHPWS_Error::logIfError($db->update());
$content[] = dgettext('filecabinet', 'Unregistered from File Cabinet.');
return true;
}
示例6: layout_install
/**
* @author Matthew McNaney <mcnaney at gmail dot com>
* @version $Id$
*/
function layout_install(&$content, $branchInstall = FALSE)
{
$page_title = 'Change this Site Name in Layout Meta Tags';
$default_theme = 'bootstrap';
if (!isset($error)) {
$db = new PHPWS_DB('layout_config');
$db->addValue('default_theme', $default_theme);
$db->addValue('page_title', $page_title);
$db->update();
$content[] = dgettext('layout', 'Layout settings updated.');
return true;
} else {
return $error;
}
}
示例7: purgeProperties
function purgeProperties()
{
$last_purge = \PHPWS_Settings::get('properties', 'last_purge') + 86400;
$current_time = time();
if ($last_purge < $current_time) {
\PHPWS_Settings::set('properties', 'last_purge', $current_time);
\PHPWS_Settings::save('properties');
$db = new PHPWS_DB('properties');
$db->addWhere('timeout', time(), '<');
$db->addValue('active', 0);
$db->update();
$db = new PHPWS_DB('prop_roommate');
$db->addWhere('timeout', time(), '<');
$db->delete();
}
}
示例8: explode
function _saveFormData()
{
$error = NULL;
/* Setup start and end values for the elements loop */
$start = $this->_position;
if ($this->_position + $this->_pageLimit > sizeof($this->_elements)) {
$end = $this->_position + (sizeof($this->_elements) - $this->_position);
} else {
$end = $this->_position + $this->_pageLimit;
}
/* Loop through elements and setup query array for database interaction */
for ($i = $start; $i < $end; $i++) {
$elementInfo = explode(':', $this->_elements[$i]);
$this->element = new $elementInfo[0]($elementInfo[1]);
if ($this->element->isRequired() && (!isset($_REQUEST['PHAT_' . $this->element->getLabel()]) || $_REQUEST['PHAT_' . $this->element->getLabel()] == NULL)) {
$error = PHPWS_Error::get(PHATFORM_REQUIRED_MISSING, 'phatform', 'PHAT_Form::_saveFormData');
}
if ($this->_editData) {
$this->_userData[$this->element->getLabel()] = $_REQUEST['PHAT_' . $this->element->getLabel()];
}
if (isset($_REQUEST['PHAT_' . $this->element->getLabel()])) {
if (is_string($_REQUEST['PHAT_' . $this->element->getLabel()]) && strlen($_REQUEST['PHAT_' . $this->element->getLabel()]) > PHAT_MAX_CHARS_TEXT_ENTRY) {
$error = PHPWS_Error::get(PHATFORM_TEXT_MAXSIZE_PASSED, 'phatform', 'PHAT_Form::_saveFormData', array($this->element->getLabel()));
}
$queryData[$this->element->getLabel()] = $_REQUEST['PHAT_' . $this->element->getLabel()];
}
}
/* If no errors occured, move the user to the next page in this form */
if (!PHPWS_Error::isError($error)) {
if ($this->currentPage() != $this->numPages()) {
$this->_position += $this->_pageLimit;
} else {
$this->_position = -1;
}
}
if (!$this->_anonymous) {
$queryData['user'] = Current_User::getUsername();
} else {
$queryData['user'] = 'anonymous';
}
$queryData['position'] = $this->_position;
$queryData['updated'] = time();
/* Check to see if this user has started entering data for this form yet */
$db = new PHPWS_DB('mod_phatform_form_' . $this->getId());
$db->addValue($queryData);
if (isset($this->_dataId)) {
$db->addWhere('id', $this->_dataId);
$db->update();
} else {
$result = $db->insert();
if (PHPWS_Error::isError($result)) {
PHPWS_Error::log($result);
} else {
$this->_dataId = $result;
}
}
return $error;
}
示例9: updateCore
public function updateCore()
{
PHPWS_Core::initModClass('boost', 'Boost.php');
$content[] = dgettext('boost', 'Updating core');
require_once PHPWS_SOURCE_DIR . 'core/boost/update.php';
$ver_info = PHPWS_Core::getVersionInfo(false);
$content[] = dgettext('boost', 'Processing update file.');
$result = core_update($content, $ver_info['version']);
if ($result === true) {
$db = new PHPWS_DB('core_version');
$file_ver = PHPWS_Core::getVersionInfo();
$db->addValue('version', $file_ver['version']);
$result = $db->update();
if (PHPWS_Error::isError($result)) {
PHPWS_Error::log($result);
$content[] = dgettext('boost', 'An error occurred updating the core.');
} else {
$content[] = dgettext('boost', 'Core successfully updated.');
}
} elseif (PHPWS_Error::isError($result)) {
PHPWS_Error::log($result);
$content[] = dgettext('boost', 'An error occurred updating the core.');
} else {
$content[] = dgettext('boost', 'An error occurred updating the core.');
}
return implode('<br />', $content);
}
示例10: updateSequenceTable
public function updateSequenceTable()
{
$this->addColumn('id', 'max');
$max_id = $this->select('one');
if (PHPWS_Error::isError($max_id)) {
return $max_id;
}
if ($max_id > 0) {
$seq_table = $this->getTable(false) . '_seq';
if (!$this->isTable($seq_table)) {
$table = $this->addPrefix($this->getTable(false));
$GLOBALS['PHPWS_DB']['connection']->nextId($table);
}
$seq = new PHPWS_DB($seq_table);
$result = $seq->select('one');
if (PHPWS_Error::logIfError($result)) {
return false;
}
$seq->addValue('id', $max_id);
if (!$result) {
return $seq->insert(false);
} else {
return $seq->update();
}
}
return true;
}
示例11: pagesmith_update
/**
* @version $Id$
* @author Matthew McNaney <mcnaney at gmail dot com>
*/
function pagesmith_update(&$content, $currentVersion)
{
$home_dir = PHPWS_Boost::getHomeDir();
switch ($currentVersion) {
case version_compare($currentVersion, '1.0.1', '<'):
$content[] = '<pre>';
$db = new PHPWS_DB('ps_page');
$result = $db->addTableColumn('front_page', 'smallint NOT NULL default 0');
if (PHPWS_Error::logIfError($result)) {
$content[] = "--- Unable to create table column 'front_page' on ps_page table.</pre>";
return false;
} else {
$content[] = "--- Created 'front_page' column on ps_page table.";
}
$files = array('templates/page_list.tpl', 'javascript/update/head.js', 'conf/error.php', 'templates/page_templates/simple/page.tpl', 'templates/page_templates/twocolumns/page.tpl');
pagesmithUpdateFiles($files, $content);
if (!PHPWS_Boost::inBranch()) {
$content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/pagesmith/boost/changes/1_0_1.txt');
}
$content[] = '</pre>';
case version_compare($currentVersion, '1.0.2', '<'):
$content[] = '<pre>';
$dest_dir = $home_dir . 'javascript/modules/pagesmith/passinfo/';
if (!is_dir($dest_dir)) {
if (is_writable($home_dir . 'javascript/modules/pagesmith/') && @mkdir($dest_dir)) {
$content[] = '--- SUCCEEDED creating "javascript/modules/passinfo/" directory.';
} else {
$content[] = 'PageSmith 1.0.2 requires the javascript/modules/pagesmith/ directory be writable.</pre>';
return false;
}
} elseif (!is_writable($dest_dir)) {
$content[] = 'PageSmith 1.0.2 requires the javascript/modules/pagesmith/passinfo/ directory be writable.</pre>';
return false;
}
$source_dir = PHPWS_SOURCE_DIR . 'mod/pagesmith/javascript/passinfo/';
if (!PHPWS_File::copy_directory($source_dir, $dest_dir)) {
$content[] = "--- FAILED copying to {$dest_dir}.</pre>";
return false;
} else {
$content[] = "--- SUCCEEDED copying to {$dest_dir} directory.";
}
if (!PHPWS_Boost::inBranch()) {
$content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/pagesmith/boost/changes/1_0_2.txt');
}
$content[] = '</pre>';
case version_compare($currentVersion, '1.0.3', '<'):
$content[] = '<pre>';
$source_dir = PHPWS_SOURCE_DIR . 'mod/pagesmith/templates/page_templates/text_only/';
$dest_dir = $home_dir . 'templates/pagesmith/page_templates/text_only/';
if (PHPWS_File::copy_directory($source_dir, $dest_dir)) {
$content[] = "--- Successfully copied {$source_dir}\n to {$dest_dir}\n";
} else {
$content[] = "--- Failed to copy {$source_dir} to {$dest_dir}</pre>";
return false;
}
$files = array('conf/config.php');
pagesmithUpdateFiles($files, $content);
if (!PHPWS_Boost::inBranch()) {
$content[] = file_get_contents(PHPWS_SOURCE_DIR . 'mod/pagesmith/boost/changes/1_0_3.txt');
}
$content[] = '</pre>';
case version_compare($currentVersion, '1.0.4', '<'):
$content[] = '<pre>';
$db = new PHPWS_DB('phpws_key');
$db->addWhere('module', 'pagesmith');
$db->addValue('edit_permission', 'edit_page');
if (PHPWS_Error::logIfError($db->update())) {
$content[] = 'Unable to update phpws_key table.</pre>';
return false;
} else {
$content[] = 'Updated phpws_key table.';
}
$content[] = '1.0.4 changes
------------------
+ Fixed pagesmith edit permission.
+ PageSmith home pages were missing edit link.</pre>';
case version_compare($currentVersion, '1.0.5', '<'):
$content[] = '<pre>';
pagesmithUpdateFiles(array('templates/page_templates/text_only/page.tpl'), $content);
$content[] = '1.0.5 changes
----------------
+ Changed wording on move to front functionality
+ Added move to front to miniadmin
+ Fixed text_only template. Missing closing div tag.
</pre>';
case version_compare($currentVersion, '1.0.6', '<'):
$content[] = '<pre>
1.0.6 changes
-------------
+ Small fix to allow linkable images on cached pages.
</pre>';
case version_compare($currentVersion, '1.0.7', '<'):
$content[] = '<pre>';
pagesmithUpdateFiles(array('templates/settings.tpl'), $content);
$content[] = '1.0.7 changes
-------------
//.........这里部分代码省略.........
示例12: doMove
function doMove()
{
if (!Current_User::authorized('wiki', 'edit_page') && !(PHPWS_Settings::get('wiki', 'allow_page_edit') && Current_User::isLogged()) || !$this->allow_edit) {
Current_User::disallow(dgettext('wiki', 'User attempted to execute a wiki page move.'));
return;
}
if (strlen($_POST['newpage']) == 0) {
WikiManager::sendMessage(dgettext('wiki', 'Please supply a new page title'), array('page_op' => 'move', 'page' => $this->getTitle(FALSE)));
}
$db = new PHPWS_DB('wiki_pages');
$db->addWhere('title', $_POST['newpage']);
$result = $db->select();
if ($result != NULL) {
WikiManager::sendMessage(dgettext('wiki', 'Page with that name already exists!'), array('page_op' => 'move', 'page' => $this->getTitle(FALSE)));
}
$this->setTitle($_POST['newpage']);
$db->reset();
$db->saveObject($this);
$db2 = new PHPWS_DB('wiki_pages_version');
$db2->addWhere('title', $_POST['page']);
$db2->addValue('title', $this->getTitle(FALSE));
$db2->update();
$db3 = new PHPWS_DB('phpws_key');
$db3->addWhere('item_id', $this->getId());
$db3->addWhere('module', 'wiki');
$db3->addValue('title', $this->getTitle());
$db3->addValue('url', (MOD_REWRITE_ENABLED ? 'wiki/' : 'index.php?module=wiki&page=') . $this->getTitle(FALSE));
$db3->update();
// Create redirect page
$redirect = new WikiPage($_POST['page']);
$redirect->setPagetext(sprintf(dgettext('wiki', 'This page has moved to %s. Please modify links to point to the new location.'), $this->getTitle(FALSE)));
$redirect->setOwnerId(Current_User::getId());
$redirect->setEditorId(Current_User::getId());
$redirect->setCreated(mktime());
$redirect->setUpdated(mktime());
$redirect->setComment(sprintf(dgettext('wiki', 'Moved page to %s.'), $this->getTitle(FALSE)));
$redirect->save();
PHPWS_Core::initModClass('version', 'Version.php');
$version = new Version('wiki_pages');
$version->setSource($redirect);
$version->setApproved(1);
$version->save();
WikiManager::sendMessage(dgettext('wiki', 'Wiki Page Moved!'), array('page' => $this->getTitle(FALSE)), FALSE);
}
示例13: calendar_update
/**
* @author Matthew McNaney <mcnaney at gmail dot com>
* @version $Id$
*/
function calendar_update(&$content, $version)
{
switch ($version) {
case version_compare($version, '1.2.2', '<'):
$content[] = 'This package will not update any versions prior to 1.2.2.';
return false;
case version_compare($version, '1.3.0', '<'):
$result = PHPWS_DB::importFile(PHPWS_SOURCE_DIR . 'mod/calendar/boost/sql_update_130.sql');
if (PHPWS_Error::isError($result)) {
PHPWS_Error::log($result);
$content[] = '+ Unable to import new suggestion table.';
return false;
} else {
$files = array('templates/admin/forms/edit_event.tpl', 'templates/view/day.tpl', 'templates/view/week.tpl', 'templates/view/month/grid.tpl', 'templates/view/month/list.tpl', 'templates/style.css', 'templates/user_main.tpl', 'templates/admin/approval.tpl', 'conf/config.php');
if (PHPWS_Boost::updateFiles($files, 'calendar')) {
$content[] = '+ Template files updated successfully.';
} else {
$content[] = '+ Unable to copy template files locally.';
$content[] = '<pre>' . implode("\n", $files) . '</pre>';
}
$content[] = '+ Suggestion table import successful';
$content[] = '<pre>
1.3.0 Changes
-------------
+ Added ability to for anonymous users to make event suggestions.
+ Fixed some issues with javascript disabled users unable to make events.
+ First public schedule is made the default on creation.
</pre>';
}
case version_compare($version, '1.4.0', '<'):
$content[] = "<pre>1.4.0 Changes\n-------------";
$files = array('templates/admin/settings.tpl', 'conf/config.php');
if (PHPWS_Boost::updateFiles($files, 'calendar')) {
$content[] = '+ Successfully copied these files locally:';
} else {
$content[] = '+ Could not copy these files locally:';
}
$content[] = ' ' . implode("\n ", $files);
$content[] = '+ Bug #1648965. Clicking Day or Week from grid view pulls correct day
+ Changed "Today" link to view appropiate description to prevent
confusion
+ Changed time defaults to %p to work with more installs
+ If start date is greater than end date, the event will be saved to
the save day.
+ Bug #1648963. Fixed mini month not showing days with events.
+ Made event count linkable in grid view
+ Labeled some permissions "unrestricted only"
+ Added permissions checks for editing and deleting
+ Created checkPermissions function in schedule class to simplify code
+ Removed commented legacy code from Schedule.php
+ Added missing suggestion tables to install and uninstall
+ Fixed caching logic
+ Fixed default schedule loading in Calendar class
+ Fixed inability to create more than one schedule
+ Added option to disable month view caching
+ Caching now works on public calendars only.
+ Added translate functions.
+ Updated message translation files.</pre>';
case version_compare($version, '1.4.1', '<'):
$content[] = "<pre>1.4.1 Changes\n-------------";
$files = array('templates/admin/forms/edit_event.tpl', 'javascript/check_date/head.js');
if (PHPWS_Boost::updateFiles($files, 'calendar')) {
$content[] = '+ Successfully updated the following files:';
} else {
$content[] = '+ Unable to update the following files:';
}
$content[] = ' ' . implode("\n ", $files);
$content[] = '+ Made noon the default time for new events.
+ Fixed Daylight Saving Time breaking repeats.
+ Delete event links made secure.
+ Days made linkable in month list view.
+ Added a sync dates button on the edit event form.';
case version_compare($version, '1.5.0', '<'):
$db = new PHPWS_DB('calendar_schedule');
$result = $db->addTableColumn('show_upcoming', 'SMALLINT NOT NULL DEFAULT 0');
if (PHPWS_Error::logIfError($result)) {
$content[] = '--- Could not create show_upcoming column in calendar_schedule table.';
return false;
}
$content[] = '<pre>';
$files = array('img/calendar.png', 'conf/config.php', 'templates/admin/forms/edit_schedule.tpl', 'templates/style.css', 'templates/view/upcoming.tpl');
if (PHPWS_Boost::updateFiles($files, 'calendar')) {
$content[] = '-- Successfully updated the following files:';
} else {
$content[] = '-- Unable to update the following files:';
}
$content[] = ' ' . implode("\n ", $files);
$content[] = '
1.5.0 Changes
---------------------
+ Can now choose to show upcoming events.
+ Removed schedule created message when using javascript popup
+ Moved getEvents function in the Schedule class
+ Increase calendar event form\'s popup height
+ Reformated schedule form
+ Bug # 1699659 - Calendar will not show "Add Event" link if a
//.........这里部分代码省略.........
示例14: saveKey
public function saveKey()
{
if (empty($this->key_id)) {
$key = new Key();
} else {
$key = new Key($this->key_id);
if (PHPWS_Error::isError($key->_error)) {
$key = new Key();
}
}
$key->setModule('signup');
$key->setItemName('sheet');
$key->setItemId($this->id);
$key->setEditPermission('edit_sheet');
if (MOD_REWRITE_ENABLED) {
$key->setUrl('signup/sheet_id/' . $this->id);
} else {
$key->setUrl('index.php?module=signup&sheet_id=' . $this->id);
}
$key->setTitle($this->title);
$result = $key->save();
if (PHPWS_Error::logIfError($result)) {
return false;
}
if (!$this->key_id) {
$this->key_id = $key->id;
$db = new PHPWS_DB('signup_sheet');
$db->addWhere('id', $this->id);
$db->addValue('key_id', $this->key_id);
PHPWS_Error::logIfError($db->update());
}
return true;
}
示例15: delete
public function delete($permanent = false)
{
$db = new PHPWS_DB('ps_page');
$db->addWhere('id', $this->id);
if ($permanent) {
$result = $db->delete();
if (PHPWS_Error::logIfError($result)) {
return false;
}
Key::drop($this->key_id);
$db = new PHPWS_DB('ps_text');
$db->addWhere('pid', $this->id);
$result = $db->delete();
$db = new PHPWS_DB('ps_block');
$db->addWhere('pid', $this->id);
$db->delete();
} else {
$db->addValue('deleted', 1);
$db->addValue('last_updated', time());
$result = $db->update();
if (PHPWS_Error::logIfError($result)) {
return false;
}
$key = new \Key($this->key_id);
$key->active = 0;
$key->save();
$key->unregister();
}
$this->removeShortcuts();
if ($this->parent_page) {
$db = new PHPWS_DB('ps_page');
$db->addWhere('parent_page', $this->parent_page);
$db->addWhere('page_order', $this->page_order, '>');
PHPWS_Error::logIfError($db->reduceColumn('page_order'));
}
return true;
}