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


PHP DBQuery::updateObject方法代码示例

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


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

示例1: store

 /**
  * @todo Parent store could be partially used
  */
 public function store(CAppUI $AppUI = null)
 {
     global $AppUI;
     $q = new DBQuery();
     $this->w2PTrimAll();
     $importing_tasks = false;
     $errorMsgArray = $this->check();
     if (count($errorMsgArray) > 0) {
         return $errorMsgArray;
     }
     if ($this->task_id) {
         addHistory('tasks', $this->task_id, 'update', $this->task_name, $this->task_project);
         // Load and globalize the old, not yet updated task object
         // e.g. we need some info later to calculate the shifting time for depending tasks
         // see function update_dep_dates
         global $oTsk;
         $oTsk = new CTask();
         $oTsk->peek($this->task_id);
         $this->task_updated = $q->dbfnNow();
         if ($this->task_start_date == '') {
             $this->task_start_date = '0000-00-00 00:00:00';
         }
         if ($this->task_end_date == '') {
             $this->task_end_date = '0000-00-00 00:00:00';
         }
         $ret = $q->updateObject('tasks', $this, 'task_id');
         $q->clear();
         $this->_action = 'updated';
         // if task_status changed, then update subtasks
         if ($this->task_status != $oTsk->task_status) {
             $this->updateSubTasksStatus($this->task_status);
         }
         // Moving this task to another project?
         if ($this->task_project != $oTsk->task_project) {
             $this->updateSubTasksProject($this->task_project);
         }
         if ($this->task_dynamic == 1) {
             $this->updateDynamics(true);
         }
         // shiftDependentTasks needs this done first
         $this->check();
         $ret = $q->updateObject('tasks', $this, 'task_id', false);
         $q->clear();
         // Milestone or task end date, or dynamic status has changed,
         // shift the dates of the tasks that depend on this task
         if ($this->task_end_date != $oTsk->task_end_date || $this->task_dynamic != $oTsk->task_dynamic || $this->task_milestone == '1') {
             $this->shiftDependentTasks();
         }
         if (!$this->task_parent) {
             $q->addTable('tasks');
             $q->addUpdate('task_parent', $this->task_id);
             $q->addUpdate('task_updated', $this->dbfnNow(), false, true);
             $q->addWhere('task_id = ' . (int) $this->task_id);
             $q->exec();
             $q->clear();
         }
     } else {
         $this->_action = 'added';
         $this->task_updated = $q->dbfnNow();
         $this->task_created = $q->dbfnNow();
         if ($this->task_start_date == '') {
             $this->task_start_date = '0000-00-00 00:00:00';
         }
         if ($this->task_end_date == '') {
             $this->task_end_date = '0000-00-00 00:00:00';
         }
         $ret = $q->insertObject('tasks', $this, 'task_id');
         $this->task_id = db_insert_id();
         $q->clear();
         addHistory('tasks', $this->task_id, 'add', $this->task_name, $this->task_project);
         if (!$this->task_parent) {
             $q->addTable('tasks');
             $q->addUpdate('task_parent', $this->task_id);
             $q->addUpdate('task_updated', $q->dbfnNow(), false, true);
             $q->addWhere('task_id = ' . (int) $this->task_id);
             $q->exec();
             $q->clear();
         } else {
             // importing tasks do not update dynamics
             $importing_tasks = true;
         }
     }
     CProject::updateTaskCount($this->task_project, $this->getTaskCount($this->task_project));
     $this->pushDependencies($this->task_id, $this->task_end_date);
     //split out related departments and store them seperatly.
     $q->setDelete('task_departments');
     $q->addWhere('task_id=' . (int) $this->task_id);
     $q->exec();
     $q->clear();
     // print_r($this->task_departments);
     if (!empty($this->task_departments)) {
         $departments = explode(',', $this->task_departments);
         foreach ($departments as $department) {
             $q->addTable('task_departments');
             $q->addInsert('task_id', $this->task_id);
             $q->addInsert('department_id', $department);
             $q->exec();
//.........这里部分代码省略.........
开发者ID:joly,项目名称:web2project,代码行数:101,代码来源:tasks.class.php

示例2: store

 public function store()
 {
     $msg = $this->check();
     if ($msg) {
         return 'CForumMessage::store-check failed ' . $msg;
     }
     $q = new DBQuery();
     if ($this->message_id) {
         // First we need to remove any forum visits for this message
         // otherwise nobody will see that it has changed.
         $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();
         $ret = $q->updateObject('forum_messages', $this, 'message_id', false);
         // ! Don't update null values
         $q->clear();
     } else {
         $date = new CDate();
         $this->message_date = $date->format(FMT_DATETIME_MYSQL);
         $new_id = $q->insertObject('forum_messages', $this, 'message_id');
         ## TODO handle error now
         echo db_error();
         ## TODO handle error better
         $q->clear();
         $q->addTable('forum_messages');
         $q->addQuery('count(message_id), MAX(message_date)');
         $q->addWhere('message_forum = ' . (int) $this->message_forum);
         $res = $q->exec();
         echo db_error();
         ## TODO handle error better
         $reply = $q->fetchRow();
         $q->clear();
         //update forum descriptor
         $forum = new CForum();
         $forum->forum_id = $this->message_forum;
         $forum->forum_message_count = $reply[0];
         $forum->forum_last_date = $reply[1];
         $forum->forum_last_id = $this->message_id;
         $forum->store();
         ## TODO handle error now
         return $this->sendWatchMail(false);
     }
     if (!$ret) {
         return 'CForumMessage::store failed ' . db_error();
     } else {
         return null;
     }
 }
开发者ID:joly,项目名称:web2project,代码行数:50,代码来源:forums.class.php

示例3: store

 public function store()
 {
     $msg = $this->check();
     if ($msg) {
         return get_class($this) . '::store-check failed';
     }
     $q = new DBQuery();
     if ($this->user_id) {
         // save the old password
         $perm_func = 'updateLogin';
         $q->addTable('users');
         $q->addQuery('user_password');
         $q->addWhere('user_id = ' . $this->user_id);
         $pwd = $q->loadResult();
         if (!$this->user_password) {
             //if the user didn't provide a password keep the old one
             $this->user_password = $pwd;
         } elseif ($pwd != $this->user_password) {
             $this->user_password = md5($this->user_password);
         } else {
             //if something is not right keep the old one
             $this->user_password = $pwd;
         }
         $q->clear();
         $ret = $q->updateObject('users', $this, 'user_id', false);
         $q->clear();
     } else {
         $perm_func = 'addLogin';
         $this->user_password = md5($this->user_password);
         $ret = $q->insertObject('users', $this, 'user_id');
         $q->clear();
     }
     if (!$ret) {
         return get_class($this) . '::store failed' . db_error();
     } else {
         $acl =& $GLOBALS['AppUI']->acl();
         $acl->{$perm_func}($this->user_id, $this->user_username);
         //Insert Default Preferences
         //Lets check if the user has allready default users preferences set, if not insert the default ones
         $q->addTable('user_preferences', 'upr');
         $q->addWhere('upr.pref_user = ' . $this->user_id);
         $uprefs = $q->loadList();
         $q->clear();
         if (!count($uprefs) && $this->user_id > 0) {
             //Lets get the default users preferences
             $q->addTable('user_preferences', 'dup');
             $q->addWhere('dup.pref_user = 0');
             $w2prefs = $q->loadList();
             $q->clear();
             foreach ($w2prefs as $w2prefskey => $w2prefsvalue) {
                 $q->addTable('user_preferences', 'up');
                 $q->addInsert('pref_user', $this->user_id);
                 $q->addInsert('pref_name', $w2prefsvalue['pref_name']);
                 $q->addInsert('pref_value', $w2prefsvalue['pref_value']);
                 $q->exec();
                 $q->clear();
             }
         }
         return null;
     }
 }
开发者ID:joly,项目名称:web2project,代码行数:61,代码来源:admin.class.php

示例4: store

 /**
  *	Inserts a new row if id is zero or updates an existing row in the database table
  *
  *	Can be overloaded/supplemented by the child class
  *	@return null|string null if successful otherwise returns and error message
  */
 public function store($updateNulls = false)
 {
     global $AppUI;
     $this->w2PTrimAll();
     $msg = $this->check();
     if ($msg) {
         return get_class($this) . '::store-check failed ' . $msg;
     }
     $k = $this->_tbl_key;
     if ($this->{$k}) {
         $store_type = 'update';
         $q = new DBQuery();
         $ret = $q->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls);
         $q->clear();
     } else {
         $store_type = 'add';
         $q = new DBQuery();
         $ret = $q->insertObject($this->_tbl, $this, $this->_tbl_key);
         $q->clear();
     }
     if ($ret) {
         // only record history if an update or insert actually occurs.
         addHistory($this->_tbl, $this->{$k}, $store_type, $AppUI->_('ACTION') . ': ' . $store_type . ' ' . $AppUI->_('TABLE') . ': ' . $this->_tbl . ' ' . $AppUI->_('ID') . ': ' . $this->{$k});
     }
     return !$ret ? get_class($this) . '::store failed ' . db_error() : null;
 }
开发者ID:joly,项目名称:web2project,代码行数:32,代码来源:w2p.class.php

示例5: store

 public function store(CAppUI $AppUI = null)
 {
     global $AppUI;
     $perms = $AppUI->acl();
     $stored = false;
     $errorMsgArray = $this->check();
     if (count($errorMsgArray) > 0) {
         return $errorMsgArray;
     }
     if ($this->dept_id) {
         $q = new DBQuery();
         $ret = $q->updateObject('departments', $this, 'dept_id', false);
         addHistory('departments', $this->dept_id, 'update', $this->dept_name, $this->dept_id);
         $stored = true;
     } else {
         $q = new DBQuery();
         $ret = $q->insertObject('departments', $this, 'dept_id');
         addHistory('departments', $this->dept_id, 'add', $this->dept_name, $this->dept_id);
         $stored = true;
     }
     return $stored;
 }
开发者ID:joly,项目名称:web2project,代码行数:22,代码来源:departments.class.php


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