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


PHP DB::beginWork方法代码示例

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


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

示例1: rebuild

 public function rebuild($start_date = null, $end_date = null)
 {
     if (!$start_date) {
         $start_date = config_option('last_sharing_table_rebuild');
     }
     if ($start_date instanceof DateTimeValue) {
         $start_date = $start_date->toMySQL();
     }
     if ($end_date instanceof DateTimeValue) {
         $end_date = $end_date->toMySQL();
     }
     if ($end_date) {
         $end_cond = "AND updated_on <= '{$end_date}'";
     }
     try {
         $object_ids = Objects::instance()->findAll(array('id' => true, "conditions" => "updated_on >= '{$start_date}' {$end_cond}"));
         $obj_count = 0;
         DB::beginWork();
         foreach ($object_ids as $id) {
             $obj = Objects::findObject($id);
             if ($obj instanceof ContentDataObject) {
                 $obj->addToSharingTable();
                 $obj_count++;
             }
         }
         set_config_option('last_sharing_table_rebuild', DateTimeValueLib::now()->toMySQL());
         DB::commit();
     } catch (Exception $e) {
         DB::rollback();
         Logger::log("Failed to rebuild sharing table: " . $e->getMessage() . "\nTrace: " . $e->getTraceAsString());
     }
     return $obj_count;
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:33,代码来源:SharingTables.class.php

示例2: purge_trash

 function purge_trash()
 {
     Env::useHelper("permissions");
     $days = config_option("days_on_trash", 0);
     $count = 0;
     if ($days > 0) {
         $date = DateTimeValueLib::now()->add("d", -$days);
         $objects = Objects::findAll(array("conditions" => array("`trashed_by_id` > 0 AND `trashed_on` < ?", $date), "limit" => 100));
         foreach ($objects as $object) {
             $concrete_object = Objects::findObject($object->getId());
             if (!$concrete_object instanceof ContentDataObject) {
                 continue;
             }
             if ($concrete_object instanceof MailContent && $concrete_object->getIsDeleted() > 0) {
                 continue;
             }
             try {
                 DB::beginWork();
                 if ($concrete_object instanceof MailContent) {
                     $concrete_object->delete(false);
                 } else {
                     $concrete_object->delete();
                 }
                 ApplicationLogs::createLog($concrete_object, ApplicationLogs::ACTION_DELETE);
                 DB::commit();
                 $count++;
             } catch (Exception $e) {
                 DB::rollback();
                 Logger::log("Error delting object in purge_trash: " . $e->getMessage(), Logger::ERROR);
             }
         }
     }
     return $count;
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:34,代码来源:Trash.class.php

示例3: console_create_user

function console_create_user($args)
{
    $fname = array_shift($args);
    $lname = array_shift($args);
    $email = array_shift($args);
    $admin = array_shift($args) == 'true';
    if (is_null($fname) || is_null($lname) || is_null($email)) {
        throw new Exception('create_user: Missing arguments. Expected: (fname, lname, email, admin)');
    }
    $display_name = $fname . " " . $lname;
    $username = str_replace(" ", "_", strtolower($display_name));
    $user_data = array('username' => $username, 'display_name' => $display_name, 'email' => $email, 'password_generator' => 'random', 'timezone' => 0, 'autodetect_time_zone' => 1, 'create_contact' => false, 'company_id' => owner_company()->getId(), 'send_email_notification' => true, 'personal_project' => 0);
    // array
    try {
        DB::beginWork();
        $user = create_user($user_data, $admin, '');
        if (!$user->getContact() instanceof Contact) {
            $contact = new Contact();
            $contact->setFirstName($fname);
            $contact->setLastName($lname);
            $contact->setEmail($email);
            $contact->setUserId($user->getId());
            $contact->save();
        }
        DB::commit();
    } catch (Exception $e) {
        DB::rollback();
        throw $e;
    }
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:30,代码来源:console.php

示例4: add

 function add()
 {
     $pt = DB::escape(array_var($_GET, 'pt'));
     $t = DB::escape(array_var($_GET, 't'));
     $dep = ProjectTaskDependencies::findOne(array('conditions' => "`previous_task_id` = {$pt} AND `task_id` = {$t}"));
     if (!$dep instanceof ProjectTaskDependency) {
         try {
             DB::beginWork();
             $dep = new ProjectTaskDependency();
             $dep->setPreviousTaskId(array_var($_GET, 'pt'));
             $dep->setTaskId(array_var($_GET, 't'));
             $dep->save();
             DB::commit();
         } catch (Exception $e) {
             flash_error($e->getMessage());
             DB::rollback();
         }
     }
     flash_success(lang('success add task dependency'));
     $reload = array_var($_GET, 'reload', true);
     if ($reload) {
         ajx_current("reload");
     } else {
         ajx_current("empty");
     }
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:26,代码来源:TaskdependencyController.class.php

示例5: isset

 function &logUserIn(User $user, $settings = null)
 {
     $existing_session_id = isset($settings['existing_session_id']) && $settings['existing_session_id'] ? $settings['existing_session_id'] : null;
     try {
         DB::beginWork('Logging user in @ ' . __CLASS__);
         $users_table = TABLE_PREFIX . 'users';
         $user_sessions_table = TABLE_PREFIX . 'user_sessions';
         $remember = (bool) array_var($settings, 'remember', false);
         $new_visit = (bool) array_var($settings, 'new_visit', false);
         // Some initial data
         $session_id = null;
         $new_expires_on = $remember ? time() + 1209600 : time() + 1800;
         // 30 minutes or 2 weeks?
         // Existing session
         if ($existing_session_id) {
             $existing_session_data = DB::executeFirstRow("SELECT remember, session_key, interface FROM {$user_sessions_table} WHERE id = ?", $existing_session_id);
             if ($existing_session_data && isset($existing_session_data['remember']) && isset($existing_session_data['session_key'])) {
                 if ($existing_session_data['remember']) {
                     $new_expires_on = time() + 1209600;
                 }
                 // if
                 $session_key = $existing_session_data['session_key'];
                 DB::execute("UPDATE {$user_sessions_table} SET user_ip = ?, user_agent = ?, last_activity_on = UTC_TIMESTAMP(), expires_on = ?, visits = visits + 1 WHERE id = ?", AngieApplication::getVisitorIp(), AngieApplication::getVisitorUserAgent(), date(DATETIME_MYSQL, $new_expires_on), $existing_session_id);
                 $session_id = $existing_session_id;
                 AngieApplication::setPreferedInterface($existing_session_data['interface']);
             }
             // if
         }
         // if
         // New session?
         if ($session_id === null) {
             AngieApplication::setPreferedInterface(array_var($settings, 'interface'));
             do {
                 $session_key = make_string(40);
             } while (DB::executeFirstCell("SELECT COUNT(id) AS 'row_count' FROM {$user_sessions_table} WHERE session_key = ?", $session_key) > 0);
             DB::execute("INSERT INTO {$user_sessions_table} (user_id, user_ip, user_agent, visits, remember, interface, created_on, last_activity_on, expires_on, session_key) VALUES (?, ?, ?, ?, ?, ?, UTC_TIMESTAMP(), ?, ?, ?)", $user->getId(), AngieApplication::getVisitorIp(), AngieApplication::getVisitorUserAgent(), 1, (int) $remember, AngieApplication::getPreferedInterface(), date(DATETIME_MYSQL), date(DATETIME_MYSQL, $new_expires_on), $session_key);
             $session_id = DB::lastInsertId();
         }
         // if
         // Update last visit time
         if ($new_visit) {
             DB::execute("UPDATE {$users_table} SET last_visit_on = last_login_on, last_login_on = ?, last_activity_on = ? WHERE id = ?", date(DATETIME_MYSQL), date(DATETIME_MYSQL), $user->getId());
         } else {
             DB::execute("UPDATE {$users_table} SET last_activity_on = ? WHERE id = ?", date(DATETIME_MYSQL), $user->getId());
         }
         // if
         DB::commit('User logged in @ ' . __CLASS__);
         $this->session_id = $session_id;
         // remember it, for logout
         Cookies::setVariable($this->session_id_var_name, "{$session_id}/{$session_key}/" . date(DATETIME_MYSQL));
         return parent::logUserIn($user);
     } catch (Exception $e) {
         DB::rollback('Failed to log user in @ ' . __CLASS__);
         throw $e;
     }
     // try
 }
开发者ID:NaszvadiG,项目名称:ACModules,代码行数:57,代码来源:FrossoProvider.class.php

示例6: createDefaultUserPermissionsAllDimension

 static function createDefaultUserPermissionsAllDimension(Contact $user, $dimension_id, $remove_previous = true)
 {
     $role_id = $user->getUserType();
     $permission_group_id = $user->getPermissionGroupId();
     $dimension = Dimensions::getDimensionById($dimension_id);
     if (!$dimension instanceof Dimension || !$dimension->getDefinesPermissions()) {
         return;
     }
     try {
         DB::beginWork();
         $shtab_permissions = array();
         $new_permissions = array();
         $role_permissions = self::findAll(array('conditions' => 'role_id = ' . $role_id));
         $members = Members::findAll(array('conditions' => 'dimension_id = ' . $dimension_id));
         foreach ($members as $member) {
             $member_id = $member->getId();
             if ($remove_previous) {
                 ContactMemberPermissions::delete("permission_group_id = {$permission_group_id} AND member_id = {$member_id}");
             }
             foreach ($role_permissions as $role_perm) {
                 if ($member->canContainObject($role_perm->getObjectTypeId())) {
                     $cmp = new ContactMemberPermission();
                     $cmp->setPermissionGroupId($permission_group_id);
                     $cmp->setMemberId($member_id);
                     $cmp->setObjectTypeId($role_perm->getObjectTypeId());
                     $cmp->setCanDelete($role_perm->getCanDelete());
                     $cmp->setCanWrite($role_perm->getCanWrite());
                     $cmp->save();
                     $new_permissions[] = $cmp;
                     $perm = new stdClass();
                     $perm->m = $member_id;
                     $perm->r = 1;
                     $perm->w = $role_perm->getCanWrite();
                     $perm->d = $role_perm->getCanDelete();
                     $perm->o = $role_perm->getObjectTypeId();
                     $shtab_permissions[] = $perm;
                 }
             }
         }
         if (count($shtab_permissions)) {
             $stCtrl = new SharingTableController();
             $stCtrl->afterPermissionChanged($permission_group_id, $shtab_permissions);
         }
         DB::commit();
         return $new_permissions;
     } catch (Exception $e) {
         DB::rollback();
         throw $e;
     }
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:50,代码来源:RoleObjectTypePermissions.class.php

示例7: healPermissionGroup

 function healPermissionGroup(SharingTableFlag $flag)
 {
     if ($flag->getObjectId() > 0) {
         try {
             $obj = Objects::findObject($flag->getObjectId());
             if (!$obj instanceof ContentDataObject) {
                 $flag->delete();
                 // if object does not exists then delete the flag
                 return;
             }
             DB::beginWork();
             // update sharing table
             $obj->addToSharingTable();
             DB::commit();
         } catch (Exception $e) {
             DB::rollback();
             Logger::log("Failed to heal object permissions for object " . $flag->getObjectId() . " (flag_id = " . $flag->getId() . ")");
             return false;
         }
         // delete flag
         $flag->delete();
         return true;
     } else {
         // heal
         $controller = new SharingTableController();
         $permissions_string = $flag->getPermissionString();
         $permission_group_id = $flag->getPermissionGroupId();
         $permissions = json_decode($permissions_string);
         if ($flag->getMemberId() > 0) {
             foreach ($permissions as $p) {
                 if (!isset($p->m)) {
                     $p->m = $flag->getMemberId();
                 }
             }
         }
         try {
             DB::beginWork();
             // update sharing table
             $controller->afterPermissionChanged($permission_group_id, $permissions);
             DB::commit();
         } catch (Exception $e) {
             DB::rollback();
             Logger::log("Failed to heal permission group {$permission_group_id} (flag_id = " . $flag->getId() . ")\n" . $e->getTraceAsString());
             return false;
         }
         // delete flag
         $flag->delete();
         return true;
     }
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:50,代码来源:SharingTableFlags.class.php

示例8: delete

 /**
  * Delete specific user
  *
  * @access public
  * @param void
  * @return null
  */
 function delete()
 {
     $this->setTemplate('del_user');
     $user = Users::findById(get_id());
     if (!$user instanceof User) {
         flash_error(lang('user dnx'));
         $this->redirectTo('administration');
     }
     // if
     if (!$user->canDelete(logged_user())) {
         flash_error(lang('no access permissions'));
         $this->redirectToReferer(get_url('dashboard'));
     }
     // if
     $delete_data = array_var($_POST, 'deleteUser');
     tpl_assign('user', $user);
     tpl_assign('delete_data', $delete_data);
     if (!is_array($delete_data)) {
         $delete_data = array('really' => 0, 'password' => '');
         // array
         tpl_assign('delete_data', $delete_data);
     } else {
         if ($delete_data['really'] == 1) {
             $password = $delete_data['password'];
             if (trim($password) == '') {
                 tpl_assign('error', new Error(lang('password value missing')));
                 return $this->render();
             }
             if (!logged_user()->isValidPassword($password)) {
                 tpl_assign('error', new Error(lang('invalid login data')));
                 return $this->render();
             }
             try {
                 DB::beginWork();
                 $user->delete();
                 ApplicationLogs::createLog($user, null, ApplicationLogs::ACTION_DELETE);
                 DB::commit();
                 flash_success(lang('success delete user', $user->getDisplayName()));
             } catch (Exception $e) {
                 DB::rollback();
                 flash_error(lang('error delete user'));
             }
             // try
             $this->redirectToUrl($user->getCompany()->getViewUrl());
         } else {
             flash_error(lang('error delete user'));
             $this->redirectToUrl($user->getCompany()->getViewUrl());
         }
     }
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:57,代码来源:UserController.class.php

示例9: core_dimensions_update_7_8

/**
 * Contact member cache
 *
 */
function core_dimensions_update_7_8()
{
    //UPDATE depth for all members
    //update root members
    DB::execute("UPDATE " . TABLE_PREFIX . "members SET depth = 1  WHERE parent_member_id = 0;");
    //clean root members
    DB::execute("UPDATE " . TABLE_PREFIX . "members SET depth = 2  WHERE parent_member_id != 0 AND depth = 1;");
    $members_depth = DB::executeAll("SELECT id FROM " . TABLE_PREFIX . "members WHERE parent_member_id =0 ORDER BY id");
    $members_depth = array_flat($members_depth);
    $members_depth = implode(",", $members_depth);
    $depth = 2;
    $max_depth = DB::executeOne("SELECT  MAX(depth) AS depth FROM `" . TABLE_PREFIX . "members`");
    //update all depths
    for ($i = $depth; $i <= $max_depth['depth']; $i++) {
        //update members depth
        DB::execute("UPDATE " . TABLE_PREFIX . "members SET depth = " . $depth . " WHERE parent_member_id  IN (" . $members_depth . ");");
        //Get member from next depth
        $members_depth = DB::executeAll("SELECT id FROM " . TABLE_PREFIX . "members WHERE depth= " . $depth . " ORDER BY id");
        $members_depth = array_flat($members_depth);
        $members_depth = implode(",", $members_depth);
        $depth++;
    }
    //END UPDATE depth for all members
    //Load the contact member cache
    set_time_limit(0);
    ini_set('memory_limit', '512M');
    $users = Contacts::getAllUsers();
    $dimensions = Dimensions::findAll();
    $dimensions_ids = array();
    foreach ($dimensions as $dimension) {
        if ($dimension->getDefinesPermissions()) {
            $dimensions_ids[] = $dimension->getId();
        }
    }
    $dimensions_ids = implode(",", $dimensions_ids);
    $root_members = DB::executeAll("SELECT * FROM " . TABLE_PREFIX . "members WHERE dimension_id IN (" . $dimensions_ids . ") AND parent_member_id=0 ORDER BY id");
    foreach ($users as $user) {
        try {
            DB::beginWork();
            foreach ($root_members as $member) {
                ContactMemberCaches::updateContactMemberCache($user, $member['id'], $member['parent_member_id']);
            }
            DB::commit();
        } catch (Exception $e) {
            DB::rollback();
            throw $e;
        }
    }
    //END Load the contact member cache
}
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:54,代码来源:update.php

示例10: purge_trash

 function purge_trash()
 {
     Env::useHelper("permissions");
     $days = config_option("days_on_trash", 0);
     $count = 0;
     if ($days > 0) {
         $date = DateTimeValueLib::now()->add("d", -$days);
         $managers = array('Comments', 'Companies', 'Contacts', 'MailContents', 'ProjectCharts', 'ProjectEvents', 'ProjectFiles', 'ProjectFileRevisions', 'ProjectForms', 'ProjectMessages', 'ProjectMilestones', 'ProjectTasks', 'ProjectWebpages');
         foreach ($managers as $manager_class) {
             $manager = new $manager_class();
             $prevcount = -1;
             while ($prevcount != $count) {
                 $prevcount = $count;
                 if ($manager_class == 'MailContents') {
                     $objects = $manager->findAll(array("include_trashed" => true, "conditions" => array("`trashed_by_id` > 0 AND `trashed_on` < ? AND `is_deleted` = 0", $date), "limit" => 100));
                 } else {
                     $objects = $manager->findAll(array("include_trashed" => true, "conditions" => array("`trashed_by_id` > 0 AND `trashed_on` < ?", $date), "limit" => 100));
                 }
                 if (is_array($objects)) {
                     // delete one by one because each one knows what else to delete
                     foreach ($objects as $o) {
                         try {
                             DB::beginWork();
                             $ws = $o->getWorkspaces();
                             if ($o instanceof MailContent) {
                                 $o->delete(false);
                             } else {
                                 $o->delete();
                             }
                             ApplicationLogs::createLog($o, $ws, ApplicationLogs::ACTION_DELETE);
                             DB::commit();
                             $count++;
                         } catch (Exception $e) {
                             DB::rollback();
                             Logger::log("Error deleting object in purge_trash: " . $e->getMessage(), Logger::ERROR);
                         }
                     }
                 }
             }
         }
     }
     return $count;
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:43,代码来源:Trash.class.php

示例11: store

 function store()
 {
     ob_end_clean();
     if (isset($_POST['message'])) {
         DB::beginWork();
         $user = $_POST['from'];
         //$sql = "insert into " . DB_PREFIX . "`email_in` (created_by, raw) values (";
         $sql = "insert into `PP086_email_in` (created_by, raw) values (";
         $sql .= "'{$user}', '" . mysql_real_escape_string($_POST['message']) . "')";
         DB::execute($sql);
         //ApplicationLogs::createLog('new email received', null, ApplicationLogs::ACTION_ADD);
         DB::commit();
         //header($_SERVER['SERVER_PROTOCOL'] . ' 200 OK');
         //header('Status: 200');
         echo 'ok';
         die;
     }
     header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
     header('Status: 404 Not Found');
     die;
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:21,代码来源:EmailController.class.php

示例12: createLog

	static function createLog($title, $log_data, $category = null) {
		if(is_null($category)) {
			$category = self::ADM_LOG_CATEGORY_SYSTEM;
		} // if
		if(!self::isValidCategory($category)) {
			throw new Error("'$category' is not valid administration log category");
		} // if

		$log = new AdministrationLog();
		try {
			DB::beginWork();
	
			$log->setTitle($title);
			$log->setLogData($log_data);
			$log->setCategory($category);
			$log->save();
		
			DB::commit();
		} catch (Exception $e) {
			DB::rollback();
		}
		return $log;
	} // createLog
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:23,代码来源:AdministrationLogs.class.php

示例13: createLog

 static function createLog($num, $log_data, $category = null)
 {
     if (is_null($category)) {
         $category = self::SMS_LOG_CATEGORY_FAILURE;
     }
     // if
     if (!self::isValidCategory($category)) {
         throw new Error("'{$category}' is not valid sms log category");
     }
     // if
     $log = new SmsLog();
     try {
         DB::beginWork();
         $log->setNumber($num);
         $log->setLogData($log_data);
         $log->setCategory($category);
         $log->save();
         DB::commit();
     } catch (Exception $e) {
         DB::rollback();
     }
     return $log;
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:23,代码来源:SmsLogs.class.php

示例14: update_unset_billing_values

 function update_unset_billing_values()
 {
     ajx_current("empty");
     if (!logged_user()->isAdministrator()) {
         flash_error(lang("no access permissions"));
         return;
     }
     try {
         DB::beginWork();
         $count = Timeslots::updateBillingValues();
         DB::commit();
         flash_success(lang("success update billing values", $count));
     } catch (Exception $e) {
         DB::rollback();
         flash_error($e->getMessage());
     }
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:17,代码来源:BillingController.class.php

示例15: addToStatus

	function addToStatus($amount) {
		try {
			DB::beginWork();
			$state = -1;
			$saved = "false";
			$state = $this->getState();
			$this->setState($state + $amount);
			$this->save();
			$saved = "true";
			DB::commit();
			return true;
		} catch (Exception $e) {
			Logger::log("Could not advance email state, email skipped: ".$e->getMessage()."\nmail_id=".$this->getId()."\nstate=$state\nsaved=$saved");
			DB::rollback();
		}
		return false;
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:17,代码来源:MailContent.class.php


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