当前位置: 首页>>代码示例>>PHP>>正文


PHP DBUtil::autoUpdate方法代码示例

本文整理汇总了PHP中DBUtil::autoUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtil::autoUpdate方法的具体用法?PHP DBUtil::autoUpdate怎么用?PHP DBUtil::autoUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBUtil的用法示例。


在下文中一共展示了DBUtil::autoUpdate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fixUnits

 function fixUnits()
 {
     // First, assign the unit to a group directly on the group
     // table, not via the group_units table, since groups could only
     // belong to a single unit anyway.
     $sGULTable = KTUtil::getTableName("groups_units");
     $sGroupsTable = KTUtil::getTableName('groups');
     $aGroupUnits = DBUtil::getResultArray("SELECT group_id, unit_id FROM {$sGULTable}");
     foreach ($aGroupUnits as $aRow) {
         // $curunit = DBUtil::getOneResultKey(array("SELECT unit_id FROM $sGroupsTable WHERE id = ?", array($aRow['group_id'])), "unit_id");
         DBUtil::autoUpdate($sGroupsTable, array('unit_id' => $aRow['unit_id']), $aRow['group_id']);
     }
     // Now, assign the unit folder id to the unit directly, instead
     // of storing the unit_id on every folder beneath the unit
     // folder.
     $sFoldersTable = KTUtil::getTableName('folders');
     $sUnitsTable = KTUtil::getTableName('units');
     $sQuery = "SELECT id FROM folders WHERE unit_id = ? ORDER BY LENGTH(parent_folder_ids) LIMIT 1";
     $aUnitIds = DBUtil::getResultArrayKey("SELECT id FROM {$sUnitsTable}", 'id');
     foreach ($aUnitIds as $iUnitId) {
         $aParams = array($iUnitId);
         $iFolderId = DBUtil::getOneResultKey(array($sQuery, $aParams), 'id');
         if (!empty($iFolderId)) {
             DBUtil::autoUpdate($sUnitsTable, array('folder_id' => $iFolderId), $iUnitId);
         }
     }
     return true;
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:28,代码来源:UpgradeFunctions.inc.php

示例2: updateTask

function updateTask($aFieldValues, $iId)
{
    DBUtil::autoUpdate('scheduler_tasks', $aFieldValues, $iId);
}
开发者ID:5haman,项目名称:knowledgetree,代码行数:4,代码来源:scheduler.php

示例3: do_resetPassword

 function do_resetPassword()
 {
     $email = $_REQUEST['email'];
     $user = $_REQUEST['username'];
     $password = $_REQUEST['password'];
     $confirm = $_REQUEST['confirm'];
     if (!($password == $confirm)) {
         return _kt('The passwords do not match, please re-enter them.');
     }
     $password = md5($password);
     // Get user from db
     $sQuery = 'SELECT id FROM users WHERE username = ? AND email = ?';
     $aParams = array($user, $email);
     $id = DBUtil::getOneResultKey(array($sQuery, $aParams), 'id');
     if (!is_numeric($id) || $id < 1) {
         //PEAR::isError($res) || is_null($res)){
         return _kt('Please check that you have entered a valid username and email address.');
     }
     // Check expiry
     $expiry = KTUtil::getSystemSetting('password_reset_expire-' . $id);
     if ($expiry < time()) {
         return _kt('The password reset key has expired, please send a new request.');
     }
     // Update password
     $res = DBUtil::autoUpdate('users', array('password' => $password), $id);
     if (PEAR::isError($res) || is_null($res)) {
         return _kt('Your password could not be reset, please try again.');
     }
     // Unset expiry date and key
     KTUtil::setSystemSetting('password_reset_expire-' . $id, '');
     KTUtil::setSystemSetting('password_reset_key-' . $id, '');
     // Email confirmation
     $url = KTUtil::addQueryStringSelf('');
     $subject = APP_NAME . ': ' . _kt('password successfully reset');
     $body = '<dd><p>';
     $body .= _kt('Your password has been successfully reset, click the link below to login.');
     $body .= "</p><p><a href = '{$url}'>" . _kt('Login') . '</a></p></dd>';
     $oEmail = new Email();
     $res = $oEmail->send($email, $subject, $body);
     if ($res === true) {
         return _kt('Your password has been successfully reset.');
     }
     return _kt('An error occurred while sending the email, please try again or contact the System Administrator.');
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:44,代码来源:loginResetDispatcher.php

示例4: updatePosition

 /**
  * Update the position of a column
  */
 function updatePosition($iId, $position)
 {
     $aFields = array('position' => $position);
     DBUtil::autoUpdate('column_entries', $aFields, $iId);
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:8,代码来源:columnentry.inc.php

示例5: saveSettings

 /**
  * Save any modified settings, clear the cached settings and return the new settings
  *
  * @param array $currentSettings
  * @return array
  */
 function saveSettings($currentSettings, $log = false)
 {
     $newSettings = isset($_POST['configArray']) ? $_POST['configArray'] : '';
     if (!empty($newSettings)) {
         $this->addInfoMessage(_kt('The configuration settings have been updated.'));
         if ($log) {
             $comment = array();
         }
         // If the value in the post array is different from the current value, then update the DB
         foreach ($currentSettings as $setting) {
             $new = $newSettings[$setting['id']];
             if ($setting['value'] != $new) {
                 // Update the value
                 $res = DBUtil::autoUpdate('config_settings', array('value' => $new), $setting['id']);
                 if (PEAR::isError($res)) {
                     $this->addErrorMessage(sprintf(_kt("The setting %s could not be updated: %s"), $setting['display_name'], $res->getMessage()));
                 }
                 if ($log) {
                     $comment[] = sprintf(_kt("%s from %s to %s"), $setting['display_name'], $setting['value'], $new);
                 }
             }
         }
         if ($log) {
             $this->logTransaction($comment);
         }
         // Clear the cached settings
         $oKTConfig = new KTConfig();
         $oKTConfig->clearCache();
         // Get the new settings from the DB
         $currentSettings = $this->getSettings();
     }
     return $currentSettings;
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:39,代码来源:configSettings.php

示例6: registerPluginHelper

 /**
  * Register the plugin in the DB
  *
  * @param unknown_type $sClassName
  * @param unknown_type $path
  * @param unknown_type $object
  * @param unknown_type $type
  */
 function registerPluginHelper($sNamespace, $sClassName, $path, $object, $view, $type)
 {
     $sql = "SELECT id FROM plugin_helper WHERE namespace = '{$sNamespace}' AND classtype = '{$type}'";
     $res = DBUtil::getOneResult($sql);
     $aValues = array();
     $aValues['namespace'] = $sNamespace;
     $aValues['plugin'] = !empty($this->sNamespace) ? $this->sNamespace : $sNamespace;
     $aValues['classname'] = $sClassName;
     $aValues['pathname'] = $path;
     $aValues['object'] = $object;
     $aValues['viewtype'] = $view;
     $aValues['classtype'] = $type;
     // if record exists - update it.
     if (!empty($res)) {
         $id = $res['id'];
         $updateRes = DBUtil::autoUpdate('plugin_helper', $aValues, $id);
         if (PEAR::isError($updateRes)) {
             return $updateRes;
         }
         return true;
     }
     // Insert into DB
     $res = DBUtil::autoInsert('plugin_helper', $aValues);
     if (PEAR::isError($res)) {
         return $res;
     }
     return true;
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:36,代码来源:plugin.inc.php

示例7: copy

 function copy($oDocument, $oDestinationFolder, $sReason = null, $sDestinationDocName = null)
 {
     // 1. generate a new triad of content, metadata and core objects.
     // 2. update the storage path.
     //print '--------------------------------- BEFORE';
     //print_r($oDocument);
     // TODO: this is not optimal. we have get() functions that will do SELECT when we already have the data in arrays
     // get the core record to be copied
     $sDocumentTable = KTUtil::getTableName('documents');
     $sQuery = 'SELECT * FROM ' . $sDocumentTable . ' WHERE id = ?';
     $aParams = array($oDocument->getId());
     $aCoreRow = DBUtil::getOneResult(array($sQuery, $aParams));
     // we unset the id as a new one will be created on insert
     unset($aCoreRow['id']);
     // get a copy of the latest metadata version for the copied document
     $iOldMetadataId = $aCoreRow['metadata_version_id'];
     $sMetadataTable = KTUtil::getTableName('document_metadata_version');
     $sQuery = 'SELECT * FROM ' . $sMetadataTable . ' WHERE id = ?';
     $aParams = array($iOldMetadataId);
     $aMDRow = DBUtil::getOneResult(array($sQuery, $aParams));
     // we unset the id as a new one will be created on insert
     unset($aMDRow['id']);
     // set the name for the document, possibly using name collission
     if (empty($sDestinationDocName)) {
         $aMDRow['name'] = KTDocumentUtil::getUniqueDocumentName($oDestinationFolder, $aMDRow['name']);
     } else {
         $aMDRow['name'] = $sDestinationDocName;
     }
     // get a copy of the latest content version for the copied document
     $iOldContentId = $aMDRow['content_version_id'];
     $sContentTable = KTUtil::getTableName('document_content_version');
     $sQuery = 'SELECT * FROM ' . $sContentTable . ' WHERE id = ?';
     $aParams = array($iOldContentId);
     $aContentRow = DBUtil::getOneResult(array($sQuery, $aParams));
     // we unset the id as a new one will be created on insert
     unset($aContentRow['id']);
     // set the filename for the document, possibly using name collission
     if (empty($sDestinationDocName)) {
         $aContentRow['filename'] = KTDocumentUtil::getUniqueFilename($oDestinationFolder, $aContentRow['filename']);
     } else {
         $aContentRow['filename'] = $sDestinationDocName;
     }
     // create the new document record
     $aCoreRow['modified'] = date('Y-m-d H:i:s');
     $aCoreRow['folder_id'] = $oDestinationFolder->getId();
     // new location.
     $id = DBUtil::autoInsert($sDocumentTable, $aCoreRow);
     if (PEAR::isError($id)) {
         return $id;
     }
     $iNewDocumentId = $id;
     // create the new metadata record
     $aMDRow['document_id'] = $iNewDocumentId;
     $aMDRow['description'] = $aMDRow['name'];
     $id = DBUtil::autoInsert($sMetadataTable, $aMDRow);
     if (PEAR::isError($id)) {
         return $id;
     }
     $iNewMetadataId = $id;
     // the document metadata version is still pointing to the original
     $aCoreUpdate = array();
     $aCoreUpdate['metadata_version_id'] = $iNewMetadataId;
     $aCoreUpdate['metadata_version'] = 0;
     // create the new content version
     $aContentRow['document_id'] = $iNewDocumentId;
     $id = DBUtil::autoInsert($sContentTable, $aContentRow);
     if (PEAR::isError($id)) {
         return $id;
     }
     $iNewContentId = $id;
     // the metadata content version is still pointing to the original
     $aMetadataUpdate = array();
     $aMetadataUpdate['content_version_id'] = $iNewContentId;
     $aMetadataUpdate['metadata_version'] = 0;
     // apply the updates to the document and metadata records
     $res = DBUtil::autoUpdate($sDocumentTable, $aCoreUpdate, $iNewDocumentId);
     if (PEAR::isError($res)) {
         return $res;
     }
     $res = DBUtil::autoUpdate($sMetadataTable, $aMetadataUpdate, $iNewMetadataId);
     if (PEAR::isError($res)) {
         return $res;
     }
     // now, we have a semi-sane document object. get it.
     $oNewDocument = Document::get($iNewDocumentId);
     //print '--------------------------------- AFTER';
     //print_r($oDocument);
     //print '======';
     //print_r($oNewDocument);
     // copy the metadata from old to new.
     $res = KTDocumentUtil::copyMetadata($oNewDocument, $iOldMetadataId);
     if (PEAR::isError($res)) {
         return $res;
     }
     // Ensure the copied document is not checked out
     $oNewDocument->setIsCheckedOut(false);
     $oNewDocument->setCheckedOutUserID(-1);
     // finally, copy the actual file.
     $oStorage =& KTStorageManagerUtil::getSingleton();
     $res = $oStorage->copy($oDocument, $oNewDocument);
//.........这里部分代码省略.........
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:101,代码来源:documentutil.inc.php


注:本文中的DBUtil::autoUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。