function delUser($id) { $where = "id={$id}"; $totalCap = getCityCapById(getcIdById($id)) - getCapById($id); $sql = "update biogas_city set totalCap=" . $totalCap . " where id=" . getcIdById($id); mysql_query($sql); //更新城市的总池容 $res = delete("biogas_user", $where); $userImgs = getAllImgByUserId($id); if ($userImgs && is_array($userImgs)) { foreach ($userImgs as $userImg) { if (file_exists("../uploads/" . $userImg['albumPath'])) { unlink("../uploads/" . $userImg['albumPath']); } } } $where1 = "uid={$id}"; if ($userImgs && is_array($userImgs)) { $res1 = delete("biogas_album", $where1); if ($res && $res1) { $mes = "删除成功!<br/><a href='listUser.php' target='mainFrame'>查看用户列表</a>"; } else { $mes = "删除失败!<br/><a href='listUser.php' target='mainFrame'>重新删除</a>"; } } else { if ($res) { $mes = "删除成功!<br/><a href='listUser.php' target='mainFrame'>查看用户列表</a>"; } else { $mes = "删除失败!<br/><a href='listUser.php' target='mainFrame'>重新删除</a>"; } } return $mes; }
function queryTotalGas($id) { $pinyin = getPinyinById($id)['pinyin']; $capacity = getCityCapById($id); $arr = $_POST; $bTemp = $arr['bTime']; $lb = strlen($bTemp); $bTime = substr($bTemp, $lb - 2, 2) . "-" . substr($bTemp, 0, 2) . "-" . substr($bTemp, 3, 2); // string $eTemp = $arr['eTime']; $le = strlen($eTemp); $eTime = substr($eTemp, $le - 2, 2) . "-" . substr($eTemp, 0, 2) . "-" . substr($eTemp, 3, 2); // string $bsql = "select id from " . $pinyin . "_tmp where date=" . "\"" . $bTime . "\""; $esql = "select id from " . $pinyin . "_tmp where date=" . "\"" . $eTime . "\""; $bId = fetchOne($bsql)['id']; $eId = fetchOne($esql)['id']; // 得到两个日期所对应的id $l_sql = "select l_tmp from " . $pinyin . "_tmp where id>=" . $bId . " and id<=" . $eId; $h_sql = "select h_tmp from " . $pinyin . "_tmp where id>=" . $bId . " and id<=" . $eId; $l_tmp = fetchAll($l_sql); $l_res = array(); // low_temperature $h_tmp = fetchAll($h_sql); $h_res = array(); // high_temperature $m_res = array(); // mid_temperature $gas_res = array(); // 产气量 $gas_total = 0; for ($i = 0; $i < count($l_tmp); $i++) { $l_res[$i] = $l_tmp[$i]['l_tmp']; $h_res[$i] = $h_tmp[$i]['h_tmp']; $m_res[$i] = ($h_res[$i] + $l_res[$i]) / 2; $gas_res[$i] = (0.01 * $m_res[$i] - 0.02) * $capacity; if ($gas_res[$i] < 0) { // 即不产生沼气的情况 $gas_res[$i] = 0; } $gas_total = $gas_total + $gas_res[$i]; } return $gas_total; }