本文整理汇总了PHP中w2p_Database_Query::addUpdate方法的典型用法代码示例。如果您正苦于以下问题:PHP w2p_Database_Query::addUpdate方法的具体用法?PHP w2p_Database_Query::addUpdate怎么用?PHP w2p_Database_Query::addUpdate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类w2p_Database_Query
的用法示例。
在下文中一共展示了w2p_Database_Query::addUpdate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
public function store($object_id)
{
global $db;
$object_id = (int) $object_id;
if ($object_id) {
$this->value_intvalue = (int) $this->value_intvalue;
$ins_charvalue = $this->value_charvalue == null ? '' : stripslashes($this->value_charvalue);
$q = new w2p_Database_Query();
$q->addTable('custom_fields_values');
if ($this->value_id) {
$q->addUpdate('value_charvalue', $ins_charvalue);
$q->addUpdate('value_intvalue', $this->value_intvalue);
$q->addWhere('value_id = ' . $this->value_id);
} else {
$q->addInsert('value_module', '');
$q->addInsert('value_field_id', $this->field_id);
$q->addInsert('value_object_id', $object_id);
$q->addInsert('value_charvalue', $ins_charvalue);
$q->addInsert('value_intvalue', $this->value_intvalue);
}
$rs = $q->exec();
$q->clear();
if (!$rs) {
return $db->ErrorMsg() . ' | SQL: ';
}
} else {
return 'Error: Cannot store field (' . $this->field_name . '), associated id not supplied.';
}
}
示例2: _compactModuleUIOrder
protected function _compactModuleUIOrder()
{
$q = new w2p_Database_Query();
$q->addTable('modules');
$q->addQuery('mod_id');
$q->addOrder('mod_ui_order ASC');
$q->addOrder('mod_directory ASC');
$moduleList = $q->loadList();
$i = 1;
foreach ($moduleList as $module) {
$q->clear();
$q->addTable('modules');
$q->addUpdate('mod_ui_order', $i);
$q->addWhere('mod_id = ' . $module['mod_id']);
$q->exec();
$i++;
}
}
示例3: CProject
$q = new w2p_Database_Query();
$q->addTable('tasks');
$q->addUpdate('task_percent_complete', '100');
$q->addWhere('task_id=' . (int) $val);
} else {
if ($task_priority == 'd') {
// delete task
$q = new w2p_Database_Query();
$q->setDelete('tasks');
$q->addWhere('task_id=' . (int) $val);
} else {
if ($task_priority > -2 && $task_priority < 2) {
// set priority
$q = new w2p_Database_Query();
$q->addTable('tasks');
$q->addUpdate('task_priority', $task_priority);
$q->addWhere('task_id=' . (int) $val);
}
}
}
$q->exec();
echo db_error();
$q->clear();
}
}
$AppUI->savePlace();
$proj = new CProject();
$tobj = new CTask();
$allowedProjects = $proj->getAllowedSQL($AppUI->user_id, 'pr.project_id');
$allowedTasks = $tobj->getAllowedSQL($AppUI->user_id, 'ta.task_id');
// query my sub-tasks (ignoring task parents)
示例4: sendNewPass
function sendNewPass()
{
global $AppUI;
$_live_site = w2PgetConfig('base_url');
$_sitename = w2PgetConfig('company_name');
// ensure no malicous sql gets past
$checkusername = trim(w2PgetParam($_POST, 'checkusername', ''));
$checkusername = db_escape($checkusername);
$confirmEmail = trim(w2PgetParam($_POST, 'checkemail', ''));
$confirmEmail = strtolower(db_escape($confirmEmail));
$q = new w2p_Database_Query();
$q->addTable('users');
$q->addJoin('contacts', 'con', 'user_contact = contact_id', 'inner');
$q->addQuery('user_id');
$q->addWhere('user_username = \'' . $checkusername . '\'');
/* Begin Hack */
/*
* This is a particularly annoying hack but I don't know of a better
* way to resolve #457. In v2.0, there was a refactoring to allow for
* muliple contact methods which resulted in the contact_email being
* removed from the contacts table. If the user is upgrading from
* v1.x and they try to log in before applying the database, crash.
* Info: http://bugs.web2project.net/view.php?id=457
*/
$qTest = new w2p_Database_Query();
$qTest->addTable('w2pversion');
$qTest->addQuery('max(db_version)');
$dbVersion = $qTest->loadResult();
if ($dbVersion >= 21 && $dbVersion < 26) {
$q->leftJoin('contacts_methods', 'cm', 'cm.contact_id = con.contact_id');
$q->addWhere("cm.method_value = '{$confirmEmail}'");
} else {
$q->addWhere("LOWER(contact_email) = '{$confirmEmail}'");
}
/* End Hack */
if (!($user_id = $q->loadResult()) || !$checkusername || !$confirmEmail) {
$AppUI->setMsg('Invalid username or email.', UI_MSG_ERROR);
$AppUI->redirect();
}
$newpass = makePass();
$message = $AppUI->_('sendpass0', UI_OUTPUT_RAW) . ' ' . $checkusername . ' ' . $AppUI->_('sendpass1', UI_OUTPUT_RAW) . ' ' . $_live_site . ' ' . $AppUI->_('sendpass2', UI_OUTPUT_RAW) . ' ' . $newpass . ' ' . $AppUI->_('sendpass3', UI_OUTPUT_RAW);
$subject = $_sitename . ' :: ' . $AppUI->_('sendpass4', UI_OUTPUT_RAW) . ' - ' . $checkusername;
$m = new w2p_Utilities_Mail();
// create the mail
$m->To($confirmEmail);
$m->Subject($subject);
$m->Body($message, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : '');
// set the body
$m->Send();
// send the mail
$newpass = md5($newpass);
$q->addTable('users');
$q->addUpdate('user_password', $newpass);
$q->addWhere('user_id=' . $user_id);
$cur = $q->exec();
if (!$cur) {
die('SQL error' . $database->stderr(true));
} else {
$AppUI->setMsg('New User Password created and emailed to you');
$AppUI->redirect();
}
}
示例5: die
<?php
/* $Id$ $URL$ */
if (!defined('W2P_BASE_DIR')) {
die('You should not access this file directly.');
}
$perms =& $AppUI->acl();
if (!canEdit('system')) {
$AppUI->redirect('m=public&a=access_denied');
}
$obj = new CConfig();
// set all checkboxes to false
// overwrite the true/enabled/checked checkboxes later
$q = new w2p_Database_Query();
$q->addTable('config');
$q->addUpdate('config_value', 'false');
$q->addWhere("config_type = 'checkbox'");
$rs = $q->loadResult();
$q->clear();
foreach ($_POST['w2Pcfg'] as $name => $value) {
$obj->config_name = $name;
$obj->config_value = $value;
// grab the appropriate id for the object in order to ensure
// that the db is updated well (config_name must be unique)
$obj->config_id = $_POST['w2PcfgId'][$name];
$update = false;
// This is really kludgy, but it works.. suggestions?
if (strpos($name, '_pass') !== false) {
if (1 == $_POST[$name . '_mod']) {
$update = true;
}
示例6: foreach
$ned->addDuration($obj->task_duration, $obj->task_duration_type);
} else {
// calc task time span start - end
$d = $tsd->calcDuration($ted);
// Re-add (keep) task time span for end date.
// This is independent from $obj->task_duration.
// The value returned by Date::Duration() is always in hours ('1')
$ned->addDuration($d, '1');
}
// prefer tue 16:00 over wed 8:00 as an end date
$ned = $ned->prev_working_day();
$obj->task_start_date = $nsd->format(FMT_DATETIME_MYSQL);
$obj->task_end_date = $ned->format(FMT_DATETIME_MYSQL);
$q = new w2p_Database_Query();
$q->addTable('tasks', 't');
$q->addUpdate('task_start_date', $obj->task_start_date);
$q->addUpdate('task_end_date', $obj->task_end_date);
$q->addWhere('task_id = ' . (int) $obj->task_id);
$q->addWhere('task_dynamic <> 1');
$q->exec();
$q->clear();
}
$obj->pushDependencies($obj->task_id, $obj->task_end_date);
}
// If there is a set of post_save functions, then we process them
if (isset($post_save)) {
foreach ($post_save as $post_save_function) {
$post_save_function();
}
}
if ($notify) {
示例7: updateHoursWorked
public static function updateHoursWorked($taskId, $totalHours)
{
$q = new w2p_Database_Query();
$q->addTable('tasks');
$q->addUpdate('task_hours_worked', $totalHours + 0);
$q->addWhere('task_id = ' . $taskId);
$q->exec();
$q->clear();
$q->addTable('tasks');
$q->addQuery('task_project');
$q->addWhere('task_id = ' . $taskId);
$project_id = $q->loadResult();
CProject::updateHoursWorked($project_id);
}
示例8: updatePercentComplete
public static function updatePercentComplete($project_id)
{
$working_hours = w2PgetConfig('daily_working_hours') ? w2PgetConfig('daily_working_hours') : 8;
$q = new w2p_Database_Query();
$q->addTable('projects');
$q->addQuery('SUM(t1.task_duration * t1.task_percent_complete * IF(t1.task_duration_type = 24, ' . $working_hours . ', t1.task_duration_type)) / SUM(t1.task_duration * IF(t1.task_duration_type = 24, ' . $working_hours . ', t1.task_duration_type)) AS project_percent_complete');
$q->addJoin('tasks', 't1', 'projects.project_id = t1.task_project', 'inner');
$q->addWhere('project_id = ' . $project_id . ' AND t1.task_id = t1.task_parent');
$project_percent_complete = $q->loadResult();
$q->clear();
$q->addTable('projects');
$q->addUpdate('project_percent_complete', $project_percent_complete);
$q->addWhere('project_id = ' . (int) $project_id);
$q->exec();
global $AppUI;
CTask::storeTokenTask($AppUI, $project_id);
}
示例9: hook_cron
public function hook_cron()
{
if (w2PgetConfig('system_update_check', true)) {
$lastCheck = w2PgetConfig('system_update_last_check', '');
$nowDate = new DateTime("now");
if ('' == $lastCheck) {
$checkForUpdates = true;
} else {
$systemDate = new DateTime($lastCheck);
$difference = 0;
//$nowDate->diff($systemDate)->format('%d');
$checkForUpdates = $difference >= 7 ? true : false;
}
if ($checkForUpdates) {
$AppUI = new w2p_Core_CAppUI();
$configList = array();
$moduleList = $AppUI->getLoadableModuleList();
foreach ($moduleList as $module) {
$configList[$module['mod_directory']] = $module['mod_version'];
}
$configList['w2p_ver'] = $AppUI->getVersion();
$configList['php_ver'] = PHP_VERSION;
$configList['database'] = $this->_w2Pconfig['dbtype'];
$configList['server'] = $_SERVER['SERVER_SOFTWARE'];
$configList['connector'] = php_sapi_name();
$configList['database_ver'] = mysql_get_client_info();
$libraries = array('tidy', 'json', 'libxml', 'mysql');
foreach ($libraries as $library) {
$configList[$library . '_extver'] = phpversion($library);
}
if (function_exists('gd_info')) {
$lib_version = gd_info();
$configList['gd_extver'] = $lib_version['GD Version'];
}
if (function_exists('curl_version')) {
$lib_version = curl_version();
$configList['curl_extver'] = $lib_version['version'];
}
$request = new w2p_Utilities_HTTPRequest('http://stats.web2project.net');
$request->addParameters($configList);
$result = $request->processRequest();
$data = json_decode($result);
$q = new w2p_Database_Query();
$q->addTable('config');
if ('' == w2PgetConfig('available_version', '')) {
$q->addInsert('config_name', 'available_version');
$q->addInsert('config_value', $data->w2p_ver);
$q->addInsert('config_group', 'admin_system');
$q->addInsert('config_type', 'text');
} else {
$q->addUpdate('config_value', $data->w2p_ver);
$q->addWhere("config_name = 'available_version'");
}
$q->exec();
$q->clear();
$q->addTable('config');
$q->addUpdate('config_value', date('Y-m-d H:i:s'));
$q->addWhere("config_name = 'system_update_last_check'");
$q->exec();
}
}
}
示例10: commit_updates
public function commit_updates()
{
$q = new w2p_Database_Query();
if (count($this->delete_list)) {
$q->setDelete($this->table);
$q->addWhere('queue_id IN (' . implode(',', $this->delete_list) . ')');
$q->exec();
$q->clear();
}
$this->delete_list = array();
foreach ($this->update_list as $fields) {
$q->addTable($this->table);
$q->addUpdate('queue_repeat_count', $fields['queue_repeat_count']);
$q->addUpdate('queue_start', $fields['queue_start']);
$q->addWhere('queue_id = ' . $fields['queue_id']);
$q->exec();
$q->clear();
}
$this->update_list = array();
}
示例11: gc
public function gc()
{
global $AppUI;
$max = $this->convertTime('max_lifetime');
$idle = $this->convertTime('idle_time');
// First pass is to kill any users that are logged in at the time of the session.
$where = 'UNIX_TIMESTAMP() - UNIX_TIMESTAMP(session_updated) > ' . $idle . ' OR UNIX_TIMESTAMP() - UNIX_TIMESTAMP(session_created) > ' . $max;
$q = new w2p_Database_Query();
$q->addTable('user_access_log');
$q->addUpdate('date_time_out', $q->dbfnNowWithTZ());
$q2 = new w2p_Database_Query();
$q2->addTable('sessions');
$q2->addQuery('session_user');
$q2->addWhere($where);
$q->addWhere('user_access_log_id IN ( ' . $q2->prepare() . ' )');
$q->exec();
$q->clear();
$q2->clear();
// Now we simply delete the expired sessions.
$q->setDelete('sessions');
$q->addWhere($where);
$q->exec();
$q->clear();
if (w2PgetConfig('session_gc_scan_queue')) {
// We need to scan the event queue. If $AppUI isn't created yet
// And it isn't likely that it will be, we create it and run the
// queue scanner.
if (!isset($AppUI)) {
$AppUI = new w2p_Core_CAppUI();
$queue = new w2p_System_EventQueue();
$queue->scan();
}
}
return true;
}
示例12: delete
public function delete(CAppUI $AppUI = null)
{
global $AppUI;
$perms = $AppUI->acl();
$result = false;
$this->_error = array();
if ($perms->checkModuleItem('forums', 'delete', $this->project_id)) {
$q = new w2p_Database_Query();
$q->setDelete('forum_visits');
$q->addWhere('visit_message = ' . (int) $this->message_id);
$q->exec();
// No error if this fails, it is not important.
$q->clear();
$q->addTable('forum_messages');
$q->addQuery('message_forum');
$q->addWhere('message_id = ' . (int) $this->message_id);
$forumId = $q->loadResult();
$q->clear();
$q->setDelete('forum_messages');
$q->addWhere('message_id = ' . (int) $this->message_id);
if (!$q->exec()) {
$result = db_error();
} else {
$result = null;
}
$q->clear();
$q->addTable('forum_messages');
$q->addQuery('COUNT(message_id)');
$q->addWhere('message_forum = ' . (int) $forumId);
$messageCount = $q->loadResult();
$q->clear();
$q->addTable('forums');
$q->addUpdate('forum_message_count', $messageCount);
$q->addWhere('forum_id = ' . (int) $forumId);
$q->exec();
$result = true;
}
return $result;
}
示例13:
}
if (!$file_id) {
$obj->file_owner = $AppUI->user_id;
if (!$obj->file_version_id) {
$q = new w2p_Database_Query();
$q->addTable('files');
$q->addQuery('file_version_id');
$q->addOrder('file_version_id DESC');
$q->setLimit(1);
$latest_file_version = $q->loadResult();
$q->clear();
$obj->file_version_id = $latest_file_version + 1;
} else {
$q = new w2p_Database_Query();
$q->addTable('files');
$q->addUpdate('file_checkout', '');
$q->addWhere('file_version_id = ' . (int) $obj->file_version_id);
$q->exec();
$q->clear();
}
}
$result = $obj->store($AppUI);
if (is_array($result)) {
$AppUI->setMsg($result, UI_MSG_ERROR, true);
$AppUI->holdObject($obj);
$AppUI->redirect('m=files&a=addedit');
}
if ($result) {
// Notification
$obj->load($obj->file_id);
$obj->notify($notify);
示例14: delete
public function delete(CAppUI $AppUI = null)
{
$this->_error = array();
$q = new w2p_Database_Query();
$q->addTable('billingcode');
$q->addUpdate('billingcode_status', '1');
$q->addWhere('billingcode_id = ' . (int) $this->_billingcode_id);
if (!$q->exec()) {
$q->clear();
return db_error();
} else {
$q->clear();
return true;
}
}
示例15: updateLastAction
/**
* @Function for update table user_acces_log in field date_time_lost_action
*/
public function updateLastAction($last_insert_id)
{
if ($last_insert_id > 0) {
$q = new w2p_Database_Query();
$q->addTable('user_access_log');
$q->addUpdate('date_time_last_action', "'" . $q->dbfnNowWithTZ() . "'", false, true);
$q->addWhere('user_access_log_id = ' . $last_insert_id);
$q->exec();
}
}