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


PHP db_insertObject函数代码示例

本文整理汇总了PHP中db_insertObject函数的典型用法代码示例。如果您正苦于以下问题:PHP db_insertObject函数的具体用法?PHP db_insertObject怎么用?PHP db_insertObject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: store

 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 ($pwd != $this->user_password) {
             $this->user_password = md5($this->user_password);
             addHistory($this->_tbl, $this->user_id, 'password changed', 'Password changed from IP ' . $_SERVER['REMOTE_ADDR']);
         } else {
             $this->user_password = null;
         }
         $ret = db_updateObject('users', $this, 'user_id', false);
     } else {
         $perm_func = "addLogin";
         $this->user_password = md5($this->user_password);
         $ret = db_insertObject('users', $this, 'user_id');
     }
     if (!$ret) {
         return get_class($this) . "::store failed <br />" . db_error();
     } else {
         $acl =& $GLOBALS['AppUI']->acl();
         $acl->{$perm_func}($this->user_id, $this->user_username);
         return NULL;
     }
 }
开发者ID:illuminate3,项目名称:dotproject,代码行数:34,代码来源:admin.class.php

示例2: store

 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 ($pwd != $this->user_password) {
             $this->user_password = md5($this->user_password);
         } else {
             $this->user_password = null;
         }
         $ret = db_updateObject('users', $this, 'user_id', false);
     } else {
         $perm_func = "addLogin";
         $this->user_password = md5($this->user_password);
         $ret = db_insertObject('users', $this, 'user_id');
     }
     if (!$ret) {
         return get_class($this) . "::store failed <br />" . 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");
             $dprefs = $q->loadList();
             $q->clear();
             foreach ($dprefs as $dprefskey => $dprefsvalue) {
                 $q->addTable('user_preferences', 'up');
                 $q->addInsert('pref_user', $this->user_id);
                 $q->addInsert('pref_name', $dprefsvalue['pref_name']);
                 $q->addInsert('pref_value', $dprefsvalue['pref_value']);
                 $q->exec();
                 $q->clear();
             }
         }
         return NULL;
     }
 }
开发者ID:n2i,项目名称:xvnkb,代码行数:54,代码来源:admin.class.php

示例3: store

 function store()
 {
     $msg = $this->check();
     if ($msg) {
         return get_class($this) . "::store-check failed - {$msg}";
     }
     if ($this->dept_id) {
         $ret = db_updateObject('departments', $this, 'dept_id', false);
     } else {
         $ret = db_insertObject('departments', $this, 'dept_id');
     }
     if (!$ret) {
         return get_class($this) . "::store failed <br />" . db_error();
     } else {
         return NULL;
     }
 }
开发者ID:n2i,项目名称:xvnkb,代码行数:17,代码来源:departments.class.php

示例4: store

 function store()
 {
     $msg = $this->check();
     if ($msg) {
         return get_class($this) . "::store-check failed";
     }
     if ($this->risk_id) {
         $ret = db_updateObject('risks', $this, 'risk_id');
     } else {
         $ret = db_insertObject('risks', $this, 'risk_id');
     }
     if (!$ret) {
         return get_class($this) . "::store failed <br />" . db_error();
     } else {
         return NULL;
     }
 }
开发者ID:slawekmikula,项目名称:dotproject,代码行数:17,代码来源:risks.class.php

示例5: store

 /**
  * @todo Parent store could be partially used
  */
 function store()
 {
     global $AppUI;
     $q = new DBQuery();
     $this->dPTrimAll();
     $importing_tasks = false;
     $msg = $this->check();
     if ($msg) {
         $return_msg = array(get_class($this) . '::store-check', 'failed', '-');
         if (is_array($msg)) {
             return array_merge($return_msg, $msg);
         } else {
             array_push($return_msg, $msg);
             return $return_msg;
         }
     }
     if ($this->task_id) {
         addHistory('tasks', $this->task_id, 'update', $this->task_name, $this->task_project);
         $this->_action = 'updated';
         // 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);
         // 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 = db_updateObject('tasks', $this, 'task_id', false);
         // 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();
         }
     } else {
         $this->_action = 'added';
         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 = db_insertObject('tasks', $this, 'task_id');
         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->addWhere('task_id = ' . $this->task_id);
             $q->exec();
             $q->clear();
         } else {
             // importing tasks do not update dynamics
             $importing_tasks = true;
         }
         // insert entry in user tasks
         $q->addTable('user_tasks');
         $q->addInsert('user_id', $AppUI->user_id);
         $q->addInsert('task_id', $this->task_id);
         $q->addInsert('user_type', '0');
         $q->exec();
         $q->clear();
     }
     //split out related departments and store them seperatly.
     $q->setDelete('task_departments');
     $q->addWhere('task_id=' . $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();
             $q->clear();
         }
     }
     //split out related contacts and store them seperatly.
     $q->setDelete('task_contacts');
     $q->addWhere('task_id=' . $this->task_id);
     $q->exec();
     $q->clear();
     if (!empty($this->task_contacts)) {
         $contacts = explode(',', $this->task_contacts);
         foreach ($contacts as $contact) {
             $q->addTable('task_contacts');
//.........这里部分代码省略.........
开发者ID:hoodoogurus,项目名称:dotprojecteap,代码行数:101,代码来源:tasks.class.php

示例6: store

 function store()
 {
     $q = new DBQuery();
     $q->addQuery('billingcode_id');
     $q->addTable('billingcode');
     $q->addWhere("billingcode_name = '" . $this->billingcode_name . "'");
     $q->addWhere('company_id = ' . $this->company_id);
     $found_id = $q->loadResult();
     if ($found_id && $found_id != $this->_billingcode_id) {
         return 'Billing Code::code already exists';
     } else {
         if ($this->_billingcode_id) {
             $q->addTable('billingcode');
             $q->addUpdate('billingcode_desc', $this->billingcode_desc);
             $q->addUpdate('billingcode_name', $this->billingcode_name);
             $q->addUpdate('billingcode_value', $this->billingcode_value);
             $q->addUpdate('billingcode_status', $this->billingcode_status);
             $q->addUpdate('company_id', $this->company_id);
             $q->addWhere('billingcode_id = ' . $this->_billingcode_id);
             $q->exec();
             $q->clear();
         } else {
             if (!($ret = db_insertObject('billingcode', $this, 'billingcode_id'))) {
                 return 'Billing Code::store failed <br />' . db_error();
             } else {
                 return NULL;
             }
         }
     }
 }
开发者ID:illuminate3,项目名称:dotproject,代码行数:30,代码来源:system.class.php

示例7: store

 function store()
 {
     $this->dPTrimAll();
     $msg = $this->check();
     if ($msg) {
         return get_class($this) . '::store-check failed - ' . $msg;
     }
     if ($this->project_id) {
         $ret = db_updateObject('projects', $this, 'project_id', false);
         addHistory('projects', $this->project_id, 'update', $this->project_name, $this->project_id);
     } else {
         $ret = db_insertObject('projects', $this, 'project_id');
         addHistory('projects', $this->project_id, 'add', $this->project_name, $this->project_id);
     }
     //split out related departments and store them seperatly.
     $q = new DBQuery();
     $q->setDelete('project_departments');
     $q->addWhere('project_id=' . $this->project_id);
     $q->exec();
     $q->clear();
     if ($this->project_departments) {
         $departments = explode(',', $this->project_departments);
         foreach ($departments as $department) {
             $q->addTable('project_departments');
             $q->addInsert('project_id', $this->project_id);
             $q->addInsert('department_id', $department);
             $q->exec();
             $q->clear();
         }
     }
     //split out related contacts and store them seperatly.
     $q->setDelete('project_contacts');
     $q->addWhere('project_id=' . $this->project_id);
     $q->exec();
     $q->clear();
     if ($this->project_contacts) {
         $contacts = explode(',', $this->project_contacts);
         foreach ($contacts as $contact) {
             if ($contact) {
                 $q->addTable('project_contacts');
                 $q->addInsert('project_id', $this->project_id);
                 $q->addInsert('contact_id', $contact);
                 $q->exec();
                 $q->clear();
             }
         }
     }
     return !$ret ? get_class($this) . '::store failed <br />' . db_error() : NULL;
 }
开发者ID:srinivasulurao,项目名称:jonel,代码行数:49,代码来源:projects.class.php

示例8: createsqluser

 function createsqluser($username, $password, $ldap_attribs = array())
 {
     global $db, $AppUI;
     $hash_pass = MD5($password);
     require_once $AppUI->getModuleClass("contacts");
     if (!count($ldap_attribs) == 0) {
         // Contact information based on the inetOrgPerson class schema
         $c = new CContact();
         $c->contact_first_name = $ldap_attribs["givenname"][0];
         $c->contact_last_name = $ldap_attribs["sn"][0];
         $c->contact_email = $ldap_attribs["mail"][0];
         $c->contact_phone = $ldap_attribs["telephonenumber"][0];
         $c->contact_mobile = $ldap_attribs["mobile"][0];
         $c->contact_city = $ldap_attribs["l"][0];
         $c->contact_country = $ldap_attribs["country"][0];
         $c->contact_state = $ldap_attribs["st"][0];
         $c->contact_zip = $ldap_attribs["postalcode"][0];
         $c->contact_job = $ldap_attribs["title"][0];
         //print_r($c); die();
         db_insertObject('contacts', $c, 'contact_id');
     }
     $contact_id = $c->contact_id == NULL ? "NULL" : $c->contact_id;
     $q = new DBQuery();
     $q->addTable('users');
     $q->addInsert('user_username', $username);
     $q->addInsert('user_password', $hash_pass);
     $q->addInsert('user_type', '1');
     $q->addInsert('user_contact', $c->contact_id);
     $q->exec();
     $user_id = $db->Insert_ID();
     $this->user_id = $user_id;
     $q->clear();
     $acl =& $AppUI->acl();
     $acl->insertUserRole($acl->get_group_id('anon'), $this->user_id);
 }
开发者ID:klr2003,项目名称:sourceread,代码行数:35,代码来源:authenticator.class.php

示例9: store

 function store()
 {
     $msg = $this->check();
     if ($msg) {
         return "CForumMessage::store-check failed<br />{$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 = ' . $this->message_id);
         $q->exec();
         // No error if this fails, it is not important.
         $ret = db_updateObject('forum_messages', $this, 'message_id', false);
         // ! Don't update null values
         $q->clear();
     } else {
         $this->message_date = db_datetime(time());
         $new_id = db_insertObject('forum_messages', $this, 'message_id');
         ## TODO handle error now
         echo db_error();
         ## TODO handle error better
         $q->addTable('forum_messages');
         $q->addQuery('count(message_id), MAX(message_date)');
         $q->addWhere('message_forum = ' . $this->message_forum);
         $res = $q->exec();
         echo db_error();
         ## TODO handle error better
         $reply = db_fetch_row($res);
         $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 <br />" . db_error();
     } else {
         return NULL;
     }
 }
开发者ID:illuminate3,项目名称:dotproject,代码行数:47,代码来源:forums.class.php

示例10: 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
  */
 function store($updateNulls = false)
 {
     $this->dPTrimAll();
     $msg = $this->check();
     if ($msg) {
         return get_class($this) . '::store-check failed<br />' . $msg;
     }
     $k = $this->_tbl_key;
     if ($this->{$k}) {
         $store_type = 'update';
         $ret = db_updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls);
     } else {
         $store_type = 'add';
         $ret = db_insertObject($this->_tbl, $this, $this->_tbl_key);
     }
     if ($ret) {
         // only record history if an update or insert actually occurs.
         addHistory($this->_tbl, $this->{$k}, $store_type, $this->_tbl . '_' . $store_type . '(' . $this->{$k} . ')');
     }
     return !$ret ? get_class($this) . '::store failed <br />' . db_error() : NULL;
 }
开发者ID:hoodoogurus,项目名称:dotprojecteap,代码行数:27,代码来源:dp.class.php

示例11: 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
  */
 function store($updateNulls = false)
 {
     $this->dPTrimAll();
     $msg = $this->check();
     if ($msg) {
         return get_class($this) . "::store-check failed<br />{$msg}";
     }
     $k = $this->_tbl_key;
     if ($this->{$k}) {
         addHistory($this->_tbl . '_update(' . $this->{$k} . ')', 0, $this->_tbl);
         $ret = db_updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls);
     } else {
         $ret = db_insertObject($this->_tbl, $this, $this->_tbl_key);
         addHistory($this->_tbl . '_add(' . $this->{$k} . ')', 0, $this->_tbl);
     }
     if (!$ret) {
         return get_class($this) . "::store failed <br />" . db_error();
     } else {
         return NULL;
     }
 }
开发者ID:n2i,项目名称:xvnkb,代码行数:27,代码来源:dp.class.php

示例12: store

 /**
 * @todo Parent store could be partially used
 */
 function store()
 {
     global $AppUI;
     $importing_tasks = false;
     $msg = $this->check();
     if ($msg) {
         $return_msg = array(get_class($this) . '::store-check', 'failed', '-');
         if (is_array($msg)) {
             return array_merge($return_msg, $msg);
         } else {
             array_push($return_msg, $msg);
             return $return_msg;
         }
     }
     if ($this->task_id) {
         addHistory('tasks', $this->task_id, 'update', $this->task_name, $this->task_project);
         $this->_action = 'updated';
         // Load the old task from disk
         $oTsk = new CTask();
         $oTsk->load($this->task_id);
         // 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
         $ret = db_updateObject('tasks', $this, 'task_id', false);
         // 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();
         }
     } else {
         $this->_action = 'added';
         $ret = db_insertObject('tasks', $this, 'task_id');
         addHistory('tasks', $this->task_id, 'add', $this->task_name, $this->task_project);
         if (!$this->task_parent) {
             $sql = "UPDATE tasks SET task_parent = {$this->task_id} WHERE task_id = {$this->task_id}";
             db_exec($sql);
         } else {
             // importing tasks do not update dynamics
             $importing_tasks = true;
         }
         // insert entry in user tasks
         $sql = "INSERT INTO user_tasks (user_id, task_id, user_type) VALUES ({$AppUI->user_id}, {$this->task_id}, -1)";
         db_exec($sql);
     }
     //split out related departments and store them seperatly.
     $sql = 'DELETE FROM task_departments WHERE task_id=' . $this->task_id;
     db_exec($sql);
     // print_r($this->task_departments);
     if (!empty($this->task_departments)) {
         $departments = explode(',', $this->task_departments);
         foreach ($departments as $department) {
             $sql = 'INSERT INTO task_departments (task_id, department_id) values (' . $this->task_id . ', ' . $department . ')';
             db_exec($sql);
         }
     }
     //split out related contacts and store them seperatly.
     $sql = 'DELETE FROM task_contacts WHERE task_id=' . $this->task_id;
     db_exec($sql);
     if (!empty($this->task_contacts)) {
         $contacts = explode(',', $this->task_contacts);
         foreach ($contacts as $contact) {
             $sql = 'INSERT INTO task_contacts (task_id, contact_id) values (' . $this->task_id . ', ' . $contact . ')';
             db_exec($sql);
         }
     }
     if (!$importing_tasks && $this->task_parent != $this->task_id) {
         $this->updateDynamics();
     }
     // if is child update parent task
     if ($this->task_parent != $this->task_id) {
         $pTask = new CTask();
         $pTask->load($this->task_parent);
         $pTask->updateDynamics(true);
     }
     // update dependencies
     if (!empty($this->task_id)) {
         $this->updateDependencies($this->getDependencies());
     } else {
         print_r($this);
     }
     if (!$ret) {
         return get_class($this) . "::store failed <br />" . db_error();
     } else {
         return NULL;
     }
 }
开发者ID:juliogallardo1326,项目名称:proc,代码行数:98,代码来源:tasks.class.php

示例13: store

 function store()
 {
     if (!($ret = db_insertObject('billingcode', $this, 'billingcode_id'))) {
         return "Billing Code::store failed <br />" . db_error();
     } else {
         return NULL;
     }
 }
开发者ID:Esleelkartea,项目名称:gestion-de-primeras-muestras,代码行数:8,代码来源:system.class.php


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