$trade_status = $_GPC['trade_status']; try { pdo_begin(); $order = pdo_fetch("SELECT * FROM " . tablename("uni_payorder") . " WHERE orderid = :orderid", array(":orderid" => $out_trade_no)); if (empty($order) || $order["status"] == 1) { header("location:" . $_W["siteroot"] . "web/index.php?c=site&a=entry&do=getPayResult&m=kim_financial&order_no=" . $out_trade_no); pdo_rollback(); return; } if (pdo_update("uni_payorder", array("status" => 1, "pay_time" => TIMESTAMP, "order_no" => $trade_no), array("orderid" => $out_trade_no)) > 0) { if (user_credits_update($order["uid"], $order["credittype"], $order["money"], array(2, "充值"))) { pdo_commit(); header("location:" . $_W["siteroot"] . "web/index.php?c=site&a=entry&do=getPayResult&m=kim_financial&order_no=" . $out_trade_no); return; } pdo_rollback(); } header("location:" . $_W["siteroot"] . "web/index.php?c=site&a=entry&do=getPayResult&m=kim_financial&order_no=" . $out_trade_no); } catch (Exception $e) { pdo_rollback(); } //——请根据您的业务逻辑来编写程序(以上代码仅作参考)—— ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } else { //验证失败 echo "fail"; header("location:" . $_W["siteroot"] . "web/index.php?c=site&a=entry&do=getPayResult&m=kim_financial&order_no=" . $_GPC['out_trade_no']); return; //调试用,写文本函数记录程序运行情况是否正常 //logResult("这里写入想要调试的代码变量值,或其他运行的结果记录"); }
function GetNextSubmission($projectid) { $now_utc = gmdate(FMT_DATETIMESTD); // Avoid a race condition when parallel processing. pdo_begin_transaction(); // Get the next submission to process. $query_array = pdo_single_row_query("SELECT id, filename, filesize, filemd5sum, attempts\n FROM submission\n WHERE projectid='{$projectid}' AND status=0\n ORDER BY id LIMIT 1 FOR UPDATE"); add_last_sql_error('GetNextSubmission-1'); if ($query_array === false || !array_key_exists('id', $query_array)) { pdo_rollback(); return false; } $submission_id = $query_array['id']; $new_attempts = $query_array['attempts'] + 1; // Mark it as status=1 (processing) and record started time. pdo_query("UPDATE submission SET status=1, started='{$now_utc}', " . "lastupdated='{$now_utc}', attempts={$new_attempts} " . "WHERE id='" . $submission_id . "'"); add_last_sql_error('GetNextSubmission-2'); pdo_commit(); return $query_array; }
public function edit() { global $_GPC, $_W; $id = $_GPC['id']; if (checksubmit('edit')) { $prize = $_GPC['prize']; $prize_validity = $_GPC['prize_validity']; if (empty($prize['prize_name'])) { return array(false, '奖品名称为空.', $prize); } if (intval($prize['prize_possibility']) < 0) { return array(false, '奖品概率为空.', $prize); } if (empty($prize['group_id']) || intval($prize['group_id']) <= 0) { return array(false, '所属组为空.', $prize); } if (empty($prize['description'])) { return array(false, '使用详情为空.', $prize); } if (empty($prize['prize_validity'])) { return array(false, '有效期不能为这.', $prize); } $prize['prize_validity'] = strtotime($prize['prize_validity'] . ' 23:59:59'); if (intval($prize['id']) > 0) { //修改 $prize['update_time'] = TIMESTAMP; unset($prize['prize_code']); $prize['update_time'] = TIMESTAMP; pdo_update('kim_sign_prizes', $prize, array('id' => $id)); return array(true, '修改成功.', $prize); } else { if (empty($prize['prize_code'])) { return array(false, '领奖口令为空.', $prize); } $prize['create_time'] = TIMESTAMP; unset($prize['id']); $prize['uniacid'] = $_W['uniacid']; $codes = explode("\r\n", $prize['prize_code']); if (empty($codes)) { return array(false, '领奖口令为空.', $prize); } $prize['number'] = count($codes); pdo_begin(); pdo_insert('kim_sign_prizes', $prize); $p_id = pdo_insertid(); if ($p_id > 0) { foreach ($codes as $code) { if (empty($code)) { continue; } $record = array('uid' => 0, 'prize_id' => $p_id, 'code' => $code, 'create_time' => TIMESTAMP, 'status' => 0); pdo_insert('kim_sign_prizes_record', $record); if (pdo_insertid() <= 0) { pdo_rollback(); return array(false, '添加失败.'); } } pdo_commit(); return array(true, '添加成功.', $prize); } pdo_rollback(); return array(false, '添加失败.'); } } if (intval($id) > 0) { $sql = 'SELECT * FROM ' . tablename('kim_sign_prizes') . ' WHERE `uniacid`=:uniacid AND `id`=:id'; $prize = pdo_fetch($sql, array(':uniacid' => $_W['uniacid'], ':id' => $id)); $prize['record'] = pdo_fetchall('SELECT * FROM ' . tablename('kim_sign_prizes_record') . ' WHERE `prize_id`=:prize_id', array(':prize_id' => $prize['id'])); return array(true, '', $prize); } else { $prize['group_id'] = intval($_GPC['group_id']); $prize['prize_validity'] = TIMESTAMP; } return array(true, '', $prize); }
function buy_package($user, $package_id, $total = 1) { if (empty($user) || empty($user["uid"])) { return error(-1, "用户不存在"); } if ($total <= 0) { return error(-1, "购买数必须大于1"); } if (empty($user["credit2"]) || doubleval($user["credit2"]) < 0) { return error(-1, "用户余额为0无法购买套餐."); } $group = kim_get_uni_group($package_id); if (empty($group)) { return error(-1, "模块不存在."); } $price = doubleval($group["price"]); if (intval($user['groupid']) > 0) { list($price, $discount) = check_price($price, intval($user['groupid'])); } if (doubleval($user["credit2"]) < $price * $total) { return error(-1, "用户余额不足."); } $st = get_settings(); $day = 30; if (intval($st[package_day]) > 0) { $day = intval($st[package_day]); } $package_price = $price * $total; $package_time = $total * $day * 24 * 60 * 60; load()->model("account"); $account = uni_fetch(); if (empty($account)) { return error(-1, "公众号不存在."); } $settings = uni_setting($account["uniacid"], array('groupdata')); $groupData = $settings['groupdata'] ? $settings['groupdata'] : array("endtime" => TIMESTAMP); $package_endTime = $package_time; if ($groupData["endtime"] - TIMESTAMP > 0) { $package_endTime = $groupData["endtime"] - TIMESTAMP + $package_time; } $old_package = kim_get_uni_group($account["groupid"]); try { pdo_begin(); $endtime = date("Y-m-d", TIMESTAMP + $package_endTime); load()->model('user'); $record = array(); $record['uid'] = $user["uid"]; $record['endtime'] = $endtime; user_update($record); $order_record = array("uniacid" => $account["uniacid"], "uid" => $user["uid"], "package" => $package_id, "buy_time" => TIMESTAMP, "expiration_time" => TIMESTAMP + $package_endTime); pdo_insert("users_packages", $order_record); $record_id = pdo_insertid(); if ($record_id <= 0) { throw new Exception("保存记录失败"); } //VIP时间同步 $groupData["endtime"] = $groupData["endtime"] < TIMESTAMP ? TIMESTAMP : $groupData["endtime"]; $old_over_time = date("Y-m-d", $groupData["endtime"]); $new_over_time = date("Y-m-d", TIMESTAMP + $package_endTime); $log = array(0, sprintf("自动续费: %s 套餐续费,续费前:%s 到期; 续费后:%s 到期", $group["name"], $old_over_time, $new_over_time)); if (intval($account["groupid"]) != intval($package_id)) { $surplus_price = $old_package["price"] * round(($groupData["endtime"] - TIMESTAMP) / 86400); $surplus_price = $surplus_price / $day; $surplus_time = round($surplus_price / $group["price"]) * $day; $package_endTime = $surplus_time * 24 * 60 * 60 + $package_time; $new_over_time = date("Y-m-d", TIMESTAMP + $package_endTime); $log_text = sprintf("套餐变更: <p>A、原套餐: %s , %s 到期</p><p>B、变更后: %s , %s 到期.</p>", $old_package["name"], $old_over_time, $group["name"], $new_over_time); $log = array(0, $log_text); if (pdo_update('uni_account', array('groupid' => $package_id), array('uniacid' => $account["uniacid"])) <= 0) { throw new Exception("更新套餐失败."); } } $new_groupdata = array('groupdata' => iserializer(array('isexpire' => 1, 'endtime' => TIMESTAMP + $package_endTime, 'oldgroupid' => $old_package['id'], 'is_auto' => 1))); if (pdo_update('uni_settings', $new_groupdata, array('uniacid' => $account["uniacid"])) <= 0) { throw new Exception("更新套餐失败!"); } $result = user_credits_update($user["uid"], "credit2", -$package_price, $log); if (is_error($result)) { throw new Exception($result["message"]); } $_W['account']['groupid'] = $account["uniacid"]; load()->model('module'); module_build_privileges(); pdo_update("users_packages", array("record_id" => $record_id, "status" => 1), array("id" => $record_id)); pdo_commit(); return true; } catch (Exception $e) { pdo_rollback(); return error(-1, $e->getMessage()); } return error(-1, "错误操作."); }
public function Insert() { if (strlen($this->BuildId) == 0 || !is_numeric($this->BuildId)) { echo 'BuildUpdate:Insert BuildId not set'; return false; } // Avoid a race condition when parallel processing. pdo_begin_transaction(); $buildid = qnum($this->BuildId); // Check if this update already exists. $query = pdo_query("SELECT updateid FROM build2update\n WHERE buildid={$buildid} FOR UPDATE"); $exists = pdo_num_rows($query) == 1; if ($exists) { $query_array = pdo_fetch_array($query); $this->UpdateId = $query_array['updateid']; $updateid = qnum($this->UpdateId); } // Remove previous updates if ($exists && !$this->Append) { // Parent builds share updates with their children. // So if this is a parent build remove any build2update rows // from the children here. pdo_query("DELETE FROM build2update WHERE buildid IN\n (SELECT id FROM build WHERE parentid={$buildid})"); // If the buildupdate and updatefile are not shared // we delete them as well. $query = pdo_query("SELECT buildid FROM build2update WHERE updateid={$updateid}"); if (pdo_num_rows($query) == 1) { $query = "DELETE FROM buildupdate WHERE id={$updateid}"; if (!pdo_query($query)) { add_last_sql_error('BuildUpdate Delete', 0, $this->BuildId); pdo_rollback(); return false; } $query = "DELETE FROM updatefile WHERE updateid={$updateid}"; if (!pdo_query($query)) { add_last_sql_error('BuildUpdate Delete updatefil', 0, $this->BuildId); pdo_rollback(); return false; } } $query = "DELETE FROM build2update WHERE buildid={$buildid}"; if (!pdo_query($query)) { add_last_sql_error('Build2Update Delete', 0, $this->BuildId); pdo_rollback(); return false; } $exists = false; $this->UpdateId = ''; $updateid = ''; } if (!$exists) { $this->StartTime = pdo_real_escape_string($this->StartTime); } $this->EndTime = pdo_real_escape_string($this->EndTime); $this->Command = pdo_real_escape_string($this->Command); $this->Type = pdo_real_escape_string($this->Type); if (strlen($this->Type) > 4) { $this->Type = 'NA'; } $this->Status = pdo_real_escape_string($this->Status); $this->Revision = pdo_real_escape_string($this->Revision); $this->PriorRevision = pdo_real_escape_string($this->PriorRevision); $this->Path = pdo_real_escape_string($this->Path); $nfiles = count($this->Files); $nwarnings = 0; foreach ($this->Files as $file) { if ($file->Author == 'Local User' && $file->Revision == -1) { $nwarnings++; } } if (!$exists) { $query = "INSERT INTO buildupdate\n (starttime,endtime,command,type,status,nfiles,warnings,\n revision,priorrevision,path)\n VALUES ('{$this->StartTime}','{$this->EndTime}','{$this->Command}',\n '{$this->Type}','{$this->Status}',{$nfiles},{$nwarnings},\n '{$this->Revision}','{$this->PriorRevision}','{$this->Path}')"; if (!pdo_query($query)) { add_last_sql_error('BuildUpdate Insert', 0, $this->BuildId); pdo_rollback(); return false; } $this->UpdateId = pdo_insert_id('buildupdate'); $updateid = qnum($this->UpdateId); $query = "INSERT INTO build2update (buildid,updateid)\n VALUES ({$buildid},{$updateid})\n {$this->DuplicateSQL}"; if (!pdo_query($query)) { add_last_sql_error('Build2Update Insert', 0, $this->BuildId); pdo_rollback(); return false; } // If this is a parent build, make sure that all of its children // are also associated with a buildupdate. $query = "\n INSERT INTO build2update (buildid,updateid)\n SELECT id, '{$this->UpdateId}' FROM build\n LEFT JOIN build2update ON build.id = build2update.buildid\n WHERE build2update.buildid IS NULL\n and build.parentid={$buildid}"; if (!pdo_query($query)) { add_last_sql_error('BuildUpdate Child Insert', 0, $this->BuildId); pdo_rollback(); return false; } } else { $nwarnings += $this->GetNumberOfWarnings(); $nfiles += $this->GetNumberOfFiles(); include 'config/config.php'; if ($CDASH_DB_TYPE == 'pgsql') { // pgsql doesn't have concat... $query = "UPDATE buildupdate SET\n endtime='{$this->EndTime}'," . "command=command || '{$this->Command}',\n status='{$this->Status}'," . "nfiles='{$nfiles}',warnings='{$nwarnings}'" . "WHERE id={$updateid}"; } else { $query = "UPDATE buildupdate SET\n endtime='{$this->EndTime}',\n command=CONCAT(command, '{$this->Command}'),\n status='{$this->Status}',\n nfiles='{$nfiles}',\n warnings='{$nwarnings}'\n WHERE id={$updateid}"; } if (!pdo_query($query)) { add_last_sql_error('BuildUpdate Update', 0, $this->BuildId); pdo_rollback(); return false; } } foreach ($this->Files as $file) { $file->UpdateId = $this->UpdateId; $file->Insert(); } pdo_commit(); return true; }
/** Insert a new summary */ public function Insert($append = false) { if (!$this->BuildId || !is_numeric($this->BuildId)) { echo 'CoverageSummary::Insert(): BuildId not set'; return false; } // Add the coverages // Construct the SQL query if (count($this->Coverages) > 0) { $sql = 'INSERT INTO coverage (buildid,fileid,covered,loctested,locuntested,branchstested,branchsuntested, functionstested,functionsuntested) VALUES '; $i = 0; foreach ($this->Coverages as &$coverage) { $fullpath = $coverage->CoverageFile->FullPath; // GcovTarHandler creates its own coveragefiles, no need to do // it again here. $fileid = -1; if (!empty($coverage->CoverageFile->Crc32)) { $fileid = $coverage->CoverageFile->Id; } if ($fileid === -1) { // Check if this file already exists in the database. // This could happen if CoverageLog.xml was parsed before Coverage.xml. $coveragefile = pdo_query("SELECT id FROM coveragefile AS cf\n INNER JOIN coveragefilelog AS cfl ON (cfl.fileid=cf.id)\n WHERE cf.fullpath='{$fullpath}' AND cfl.buildid='{$this->BuildId}'"); if (pdo_num_rows($coveragefile) == 0) { // Create an empty file if doesn't exist. pdo_query("INSERT INTO coveragefile (fullpath) VALUES ('{$fullpath}')"); $fileid = pdo_insert_id('coveragefile'); } else { $coveragefile_array = pdo_fetch_array($coveragefile); $fileid = $coveragefile_array['id']; } $coverage->CoverageFile->Id = $fileid; } $covered = $coverage->Covered; $loctested = $coverage->LocTested; $locuntested = $coverage->LocUntested; $branchstested = $coverage->BranchesTested; $branchsuntested = $coverage->BranchesUntested; $functionstested = $coverage->FunctionsTested; $functionsuntested = $coverage->FunctionsUntested; if (empty($covered)) { $covered = 0; } if (empty($loctested)) { $loctested = 0; } if (empty($locuntested)) { $locuntested = 0; } if (empty($branchstested)) { $branchstested = 0; } if (empty($branchsuntested)) { $branchsuntested = 0; } if (empty($functionstested)) { $functionstested = 0; } if (empty($functionsuntested)) { $functionsuntested = 0; } $this->LocTested += $loctested; $this->LocUntested += $locuntested; if ($append) { // UPDATE (instead of INSERT) if this coverage already // exists. pdo_begin_transaction(); $row = pdo_single_row_query('SELECT * FROM coverage WHERE buildid=' . qnum($this->BuildId) . ' AND fileid=' . qnum($coverage->CoverageFile->Id) . ' FOR UPDATE'); if ($row && array_key_exists('1', $row)) { $query = 'UPDATE coverage SET covered=' . qnum($covered) . ', loctested=' . qnum($loctested) . ', locuntested=' . qnum($locuntested) . ', branchstested=' . qnum($branchstested) . ', branchsuntested=' . qnum($branchsuntested) . ', functionstested=' . qnum($functionstested) . ', functionsuntested=' . qnum($functionsuntested) . ' WHERE buildid=' . qnum($this->BuildId) . ' AND fileid=' . qnum($coverage->CoverageFile->Id); if (!pdo_query($query)) { add_last_sql_error('CoverageSummary Update Coverage'); pdo_rollback(); return false; } pdo_commit(); continue; } pdo_commit(); } if ($i > 0) { $sql .= ', '; } else { $i = 1; } $sql .= '(' . qnum($this->BuildId) . ',' . qnum($fileid) . ',' . qnum($covered) . ',' . qnum($loctested) . ',' . qnum($locuntested) . ', ' . qnum($branchstested) . ',' . qnum($branchsuntested) . ',' . qnum($functionstested) . ',' . qnum($functionsuntested) . ')'; } if ($i > 0) { // Insert into coverage if (!pdo_query($sql)) { add_last_sql_error('CoverageSummary Insert Coverage'); return false; } } // Add labels foreach ($this->Coverages as &$coverage) { $coverage->InsertLabelAssociations($this->BuildId); } } $summary_updated = false; if ($append) { // Check if a coveragesummary already exists for this build. pdo_begin_transaction(); $row = pdo_single_row_query('SELECT loctested, locuntested FROM coveragesummary WHERE buildid=' . qnum($this->BuildId) . ' FOR UPDATE'); if ($row && array_key_exists('loctested', $row)) { $previous_loctested = $row['loctested']; $previous_locuntested = $row['locuntested']; // Recompute how many lines were tested & untested // based on all files covered by this build. $this->LocTested = 0; $this->LocUntested = 0; $query = 'SELECT loctested, locuntested FROM coverage WHERE buildid=' . qnum($this->BuildId); $results = pdo_query($query); if (!$results) { add_last_sql_error('CoverageSummary:GetExistingCoverage'); pdo_rollback(); return false; } while ($row = pdo_fetch_array($results)) { $this->LocTested += $row['loctested']; $this->LocUntested += $row['locuntested']; } // Update the existing record with this information. $query = 'UPDATE coveragesummary SET loctested=' . qnum($this->LocTested) . ', locuntested=' . qnum($this->LocUntested) . ' WHERE buildid=' . qnum($this->BuildId); if (!pdo_query($query)) { add_last_sql_error('CoverageSummary Update'); pdo_rollback(); return false; } $summary_updated = true; // Record how loctested and locuntested changed as a result // of this update. $delta_tested = $this->LocTested - $previous_loctested; $delta_untested = $this->LocUntested - $previous_locuntested; } pdo_commit(); } if (!$summary_updated) { $query = 'INSERT INTO coveragesummary (buildid,loctested,locuntested) VALUES (' . qnum($this->BuildId) . ',' . qnum($this->LocTested) . ',' . qnum($this->LocUntested) . ')'; if (!pdo_query($query)) { add_last_sql_error('CoverageSummary Insert'); return false; } } // If this is a child build then update the parent's summary as well. $parent = pdo_single_row_query('SELECT parentid FROM build WHERE id=' . qnum($this->BuildId)); if ($parent && array_key_exists('parentid', $parent)) { $parentid = $parent['parentid']; if ($parentid > 0) { pdo_begin_transaction(); $exists = pdo_query('SELECT * FROM coveragesummary WHERE buildid=' . qnum($parentid) . ' FOR UPDATE'); if (pdo_num_rows($exists) == 0) { $query = 'INSERT INTO coveragesummary (buildid,loctested,locuntested) VALUES (' . qnum($parentid) . ',' . qnum($this->LocTested) . ',' . qnum($this->LocUntested) . ')'; } else { if (!isset($delta_tested)) { $delta_tested = $this->LocTested; } if (!isset($delta_untested)) { $delta_untested = $this->LocUntested; } $query = 'UPDATE coveragesummary SET loctested = loctested + ' . qnum($delta_tested) . ', locuntested = locuntested + ' . qnum($delta_untested) . ' WHERE buildid=' . qnum($parentid); } if (!pdo_query($query)) { add_last_sql_error('CoverageSummary Parent Update'); pdo_rollback(); return false; } pdo_commit(); } } return true; }
/** * 链接起来两个人 */ public function doMobileCall() { global $_W, $_GPC; $this->prepare_web_config(); $uniacid = $_W['uniaccount']['uniacid']; $openid = $_W['openid']; try { $this->check_follow(); } catch (Exception $e) { return $this->return_json($e->getCode(), $e->getMessage(), null); } try { //超时会抛出异常 当不存在也会抛出异常 $relation = $this->fetch_relation_openid(); if (!empty($this->web_config['pipei_success_me'])) { $this->send_text_message($openid, $this->web_config['pipei_success_me']); } $to = $this->fetch_user_info_by_openid($relation['relation_openid']); $over_time = ceil(($relation['expire_time'] - $relation['update_time']) / 60); $to['over_minute'] = $over_time; return $this->return_json(200, '匹配成功,请关闭此页面,发送消息给公众平台即可与对方聊天', $to); } catch (Exception $e) { $relation_user = null; try { $relation_user = $this->fetch_one_relation(); } catch (Exception $e) { $this->log($e->getMessage()); return $this->return_json($e->getCode(), $e->getMessage(), null); } $to = $this->fetch_user_info_by_openid($relation_user['openid']); try { pdo_begin(); $relation = $this->create_relation($relation_user['openid']); // 提醒对方用户,已经被匹配了 $this->send_text_message($to['openid'], $this->web_config['pipei_success']); //将双方的状态改为忙碌 $this->check_buzy_status($openid); $this->check_buzy_status($to['openid']); if (!empty($this->web_config['pipei_success_me'])) { $this->send_text_message($openid, $this->web_config['pipei_success_me']); } pdo_commit(); $to['over_minute'] = $this->web_config['chat_limit_minute']; return $this->return_json(200, '匹配成功,请关闭此页面,发送消息给公众平台即可与对方聊天', $to); } catch (Exception $e) { $this->log('匹配失败,对方已经被别人匹配到'); pdo_rollback(); return $this->return_json($e->getCode(), $e->getMessage(), null); } } }
/** * Update our database record of a build so that it accurately reflects * this object and the specified number of new warnings & errors. **/ public function UpdateBuild($buildid, $newErrors, $newWarnings) { if ($buildid < 1) { return; } // Avoid a race condition when parallel processing. pdo_begin_transaction(); $clauses = array(); $build = pdo_single_row_query("SELECT builderrors, buildwarnings, starttime, endtime,\n submittime, log, command, parentid\n FROM build WHERE id='{$buildid}' FOR UPDATE"); // Special case: check if we should move from -1 to 0 errors/warnings. $errorsHandled = false; $warningsHandled = false; if ($this->InsertErrors) { if ($build['builderrors'] == -1 && $newErrors == 0) { $clauses[] = 'builderrors = 0'; $errorsHandled = true; } if ($build['buildwarnings'] == -1 && $newWarnings == 0) { $clauses[] = 'buildwarnings = 0'; $warningsHandled = true; } } // Check if we still need to modify builderrors or buildwarnings. if (!$errorsHandled) { if ($build['builderrors'] == -1) { $build['builderrors'] = 0; } if ($newErrors > 0) { $numErrors = $build['builderrors'] + $newErrors; $clauses[] = "builderrors = {$numErrors}"; } } if (!$warningsHandled) { if ($build['buildwarnings'] == -1) { $build['buildwarnings'] = 0; } if ($newWarnings > 0) { $numWarnings = $build['buildwarnings'] + $newWarnings; $clauses[] = "buildwarnings = {$numWarnings}"; } } // Check if we need to modify starttime or endtime. if (strtotime($build['starttime']) > strtotime($this->StartTime)) { $clauses[] = "starttime = '{$this->StartTime}'"; } if (strtotime($build['endtime']) < strtotime($this->EndTime)) { $clauses[] = "endtime = '{$this->EndTime}'"; } if ($build['parentid'] != -1) { // If this is not a parent build, check if its log or command // has changed. if ($this->Log && $this->Log != $build['log']) { if (!empty($build['log'])) { $log = $build['log'] . " " . $this->Log; } else { $log = $this->Log; } $clauses[] = "log = '{$log}'"; } if ($this->Command && $this->Command != $build['command']) { if (!empty($build['command'])) { $command = $build['command'] . "; " . $this->Command; } else { $command = $this->Command; } $clauses[] = "command = '{$command}'"; } } $num_clauses = count($clauses); if ($num_clauses > 0) { $query = 'UPDATE build SET ' . $clauses[0]; for ($i = 1; $i < $num_clauses; $i++) { $query .= ', ' . $clauses[$i]; } $query .= " WHERE id = '{$buildid}'"; if (!pdo_query($query)) { add_last_sql_error('UpdateBuild', $this->ProjectId, $buildid); pdo_rollback(); return false; } } pdo_commit(); // Also update the parent if necessary. $row = pdo_single_row_query("SELECT parentid FROM build WHERE id='{$buildid}'"); if ($row && array_key_exists('parentid', $row) && $row['parentid'] > 0) { if ($buildid == $row['parentid']) { // Avoid infinite recursion. // This should never happen, but we might as well be careful. add_log("{$buildid} is its own parent", 'Build::UpdateBuild', LOG_ERR, $this->ProjectId, $this->Id, CDASH_OBJECT_BUILD, $this->Id); return; } $this->UpdateBuild($row['parentid'], $newErrors, $newWarnings); if ($buildid == $this->Id) { $this->SetParentId($row['parentid']); } } }