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


PHP sql_mutex_lock函数代码示例

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


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

示例1: sql_insert_id

        $area = sql_insert_id("{$tbl_area}", "id");
    }
    // Release the mutex
    sql_mutex_unlock("{$tbl_area}");
} elseif ($type == "room") {
    // Truncate the name and description fields to the maximum length as a precaution.
    $name = substr($name, 0, $maxlength['room.room_name']);
    $description = substr($description, 0, $maxlength['room.description']);
    // Add SQL escaping
    $room_name_q = addslashes($name);
    $description_q = addslashes($description);
    if (empty($capacity)) {
        $capacity = 0;
    }
    // Acquire a mutex to lock out others who might be editing rooms
    if (!sql_mutex_lock("{$tbl_room}")) {
        fatal_error(TRUE, get_vocab("failed_to_acquire"));
    }
    // Check that the room name is unique within the area
    if (sql_query1("SELECT COUNT(*) FROM {$tbl_room} WHERE room_name='{$room_name_q}' AND area_id={$area} LIMIT 1") > 0) {
        $error = "invalid_room_name";
    } else {
        $sql = "INSERT INTO {$tbl_room} (room_name, sort_key, area_id, description, capacity)\n            VALUES ('{$room_name_q}', '{$room_name_q}', {$area}, '{$description_q}',{$capacity})";
        if (sql_command($sql) < 0) {
            trigger_error(sql_error(), E_USER_WARNING);
            fatal_error(TRUE, get_vocab("fatal_db_error"));
        }
    }
    // Release the mutex
    sql_mutex_unlock("{$tbl_room}");
}
开发者ID:JeremyJacquemont,项目名称:SchoolProjects,代码行数:31,代码来源:add.php

示例2: clean_address_list

 require_once "functions_mail.inc";
 // PHASE 2 (ROOM) - UPDATE THE DATABASE
 // ------------------------------------
 if (isset($change_room) && !empty($room)) {
     // clean up the address list replacing newlines by commas and removing duplicates
     $room_admin_email = clean_address_list($room_admin_email);
     // put a space after each comma so that the list displays better
     $room_admin_email = str_replace(',', ', ', $room_admin_email);
     // validate the email addresses
     $valid_email = validate_email_list($room_admin_email);
     if (FALSE != $valid_email) {
         if (empty($capacity)) {
             $capacity = 0;
         }
         // Acquire a mutex to lock out others who might be deleting the new area
         if (!sql_mutex_lock("{$tbl_area}")) {
             fatal_error(TRUE, get_vocab("failed_to_acquire"));
         }
         // Check the new area still exists
         if (sql_query1("SELECT COUNT(*) FROM {$tbl_area} WHERE id={$new_area} LIMIT 1") < 1) {
             $valid_area = FALSE;
         } elseif (($new_area != $old_area || $room_name != $old_room_name) && sql_query1("SELECT COUNT(*)\n                               FROM {$tbl_room}\n                              WHERE" . sql_syntax_casesensitive_equals("room_name", $room_name) . "\n                                AND area_id={$new_area}\n                              LIMIT 1") > 0) {
             $valid_room_name = FALSE;
         } else {
             // Convert booleans into 0/1 (necessary for PostgreSQL)
             $room_disabled = !empty($room_disabled) ? 1 : 0;
             $sql = "UPDATE {$tbl_room} SET ";
             $n_fields = count($fields);
             $assign_array = array();
             foreach ($fields as $field) {
                 if ($field['name'] != 'id') {
开发者ID:linuxmuster,项目名称:linuxmuster-mrbs-manager,代码行数:31,代码来源:edit_area_room.php

示例3: mrbsGetRepeatEntryList

if ($rep_type != 0) {
    $reps = mrbsGetRepeatEntryList($starttime, isset($rep_enddate) ? $rep_enddate : 0, $rep_type, $rep_opt, $max_rep_entrys, $rep_num_weeks);
}
# When checking for overlaps, for Edit (not New), ignore this entry and series:
$repeat_id = 0;
if (isset($id)) {
    $ignore_id = $id;
    $repeat_id = sql_query1("SELECT repeat_id FROM {$tbl_entry} WHERE id={$id}");
    if ($repeat_id < 0) {
        $repeat_id = 0;
    }
} else {
    $ignore_id = 0;
}
# Acquire mutex to lock out others trying to book the same slot(s).
if (!sql_mutex_lock("{$tbl_entry}")) {
    fatal_error(1, get_vocab("failed_to_acquire"));
}
# Check for any schedule conflicts in each room we're going to try and
# book in
$err = "";
foreach ($rooms as $room_id) {
    if ($rep_type != 0 && !empty($reps)) {
        if (count($reps) < $max_rep_entrys) {
            for ($i = 0; $i < count($reps); $i++) {
                # calculate diff each time and correct where events
                # cross DST
                $diff = $endtime - $starttime;
                $diff += cross_dst($reps[$i], $reps[$i] + $diff);
                $tmp = mrbsCheckFree($room_id, $reps[$i], $reps[$i] + $diff, $ignore_id, $repeat_id);
                if (!empty($tmp)) {
开发者ID:verdurin,项目名称:mrbs-mcr,代码行数:31,代码来源:edit_entry_handler.php

示例4: mrbsGetRepeatEntryList

if ($rep_type != 0) {
    $reps = mrbsGetRepeatEntryList($starttime, isset($rep_enddate) ? $rep_enddate : 0, $rep_type, $rep_opt, $max_rep_entrys, $rep_num_weeks);
}
# When checking for overlaps, for Edit (not New), ignore this entry and series:
$repeat_id = 0;
if (isset($id)) {
    $ignore_id = $id;
    $repeat_id = sql_query1("SELECT repeat_id FROM mrbs_entry WHERE id={$id}");
    if ($repeat_id < 0) {
        $repeat_id = 0;
    }
} else {
    $ignore_id = 0;
}
# Acquire mutex to lock out others trying to book the same slot(s).
if (!sql_mutex_lock('mrbs_entry')) {
    fatal_error(1, $vocab['failed_to_acquire']);
}
# Check for any schedule conflicts in each room we're going to try and
# book in
$err = "";
foreach ($rooms as $room_id) {
    if ($rep_type != 0 && !empty($reps)) {
        if (count($reps) < $max_rep_entrys) {
            $diff = $endtime - $starttime;
            for ($i = 0; $i < count($reps); $i++) {
                $tmp = mrbsCheckFree($room_id, $reps[$i], $reps[$i] + $diff, $ignore_id, $repeat_id);
                if (!empty($tmp)) {
                    $err = $err . $tmp;
                }
            }
开发者ID:verdurin,项目名称:mrbs-mcr,代码行数:31,代码来源:edit_entry_handler.php

示例5: users

    //$area = mrbsAddArea($name, $error);
    $sql = "INSERT INTO users (name, code, team, role, disabled)\n          VALUES ('{$name}', '{$code}', '{$team}', '{$role}', 0)";
    if (!sql_mutex_lock("users")) {
        fatal_error(TRUE, get_vocab("failed_to_acquire"));
    }
    if (sql_command($sql) < 0) {
        trigger_error(sql_error(), E_USER_WARNING);
        fatal_error(TRUE, get_vocab("fatal_db_error"));
    }
    $area = sql_insert_id('users', 'id');
    sql_mutex_unlock("users");
} elseif ($type == "room") {
    //$room = mrbsAddRoom($name, $area, $error, $description, $capacity);
    $f2f = $_POST['f2f'];
    $available = $_POST['available'];
    $dnka = $_POST['dnka'];
    $outreach = $_POST['outreach'];
    $nocount = $_POST['nocount'];
    $sql = "INSERT INTO codes (code, description, f2f, available, dnka, outreach, nocount, disabled)\n          VALUES ('{$code}', '{$description}', {$f2f}, {$available}, {$dnka}, {$outreach}, {$nocount}, 0)";
    if (!sql_mutex_lock("users")) {
        fatal_error(TRUE, get_vocab("failed_to_acquire"));
    }
    if (sql_command($sql) < 0) {
        trigger_error(sql_error(), E_USER_WARNING);
        fatal_error(TRUE, get_vocab("fatal_db_error"));
    }
    $area = sql_insert_id('users', 'id');
    sql_mutex_unlock("users");
}
$returl = "admin.php?success=" . (isset($area) ? 1 : 0) . (!empty($error) ? "&error={$error}" : "");
header("Location: {$returl}");
开发者ID:cvelayo,项目名称:worklog,代码行数:31,代码来源:add.php

示例6: Edit

        $rep_type, $rep_opt, $max_rep_entrys, $rep_num_weeks);

# When checking for overlaps, for Edit (not New), ignore this entry and series:
$repeat_id = 0;
if (isset($id))
{
    $ignore_id = $id;
    $repeat_id = sql_query1("SELECT repeat_id FROM $tbl_entry WHERE id=$id");
    if ($repeat_id < 0)
        $repeat_id = 0;
}
else
    $ignore_id = 0;

# Acquire mutex to lock out others trying to book the same slot(s).
if (!sql_mutex_lock("$tbl_entry"))
    fatal_error(1, get_vocab("failed_to_acquire"));
    
# Check for any schedule conflicts in each room we're going to try and
# book in
$err = "";
foreach ( $rooms as $room_id ) {
  if ($rep_type != 0 && !empty($reps))
  {
    if(count($reps) < $max_rep_entrys)
    {
        
        for($i = 0; $i < count($reps); $i++)
        {
	    # calculate diff each time and correct where events
	    # cross DST
开发者ID:verdurin,项目名称:mrbs-mcr,代码行数:31,代码来源:edit_entry_handler.php

示例7: clean_address_list

 $disabled = $_POST['disabled'];
 $id = $_POST['id'];
 if (isset($change_room) && !empty($code)) {
     /*    // clean up the address list replacing newlines by commas and removing duplicates
         $room_admin_email = clean_address_list($room_admin_email);
         // put a space after each comma so that the list displays better
         $room_admin_email = str_replace(',', ', ', $room_admin_email);
         // validate the email addresses
         $valid_email = validate_email_list($room_admin_email);*/
     if (FALSE != $valid_email) {
         /*      if (empty($capacity))
               {
                 $capacity = 0;
               }*/
         // Acquire a mutex to lock out others who might be deleting the new area
         if (!sql_mutex_lock("codes")) {
             fatal_error(TRUE, get_vocab("failed_to_acquire"));
         } else {
             // Convert booleans into 0/1 (necessary for PostgreSQL)
             /*        $room_disabled = (!empty($room_disabled)) ? 1 : 0;
                     $sql = "UPDATE $tbl_room SET ";*/
             /*        $n_fields = count($fields);
                     $assign_array = array();
                     foreach ($fields as $field)
                     {
                       if ($field['name'] != 'id')  // don't do anything with the id field
                       {
                         switch ($field['name'])
                         {
                           // first of all deal with the standard MRBS fields
                           case 'area_id':
开发者ID:cvelayo,项目名称:worklog,代码行数:31,代码来源:edit_area_room.php


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