public static function getInstance() { try { if (self::$db == null) { self::$db = new PDO("mysql:host=" . localhost . ";dbname=" . gjxms, root, root, array(PDO::ATTR_PERSISTENT => true)); self::$db->setAttribute(PDO::ATTR_AUTOCOMMIT, false); self::$db->setAttribute(PDO::ATTR_CASE, PDO::CASE_UPPER); self::$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); self::$db->exec("SET NAMES UTF8"); self::$db->exec("set sql_mode='NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'"); } return self::$db; } catch (Exception $e) { die("数据库连接失败!" . $e->getMessage()); } }
} if (isset($_GET['active']) && $_GET['active'] == "total") { $areaBean = Area::getAllAreaRecord(); $smarty->assign("areaBean", $areaBean); $smarty->display('area.html'); } else { if (isset($_GET['active']) && $_GET['active'] == "ok") { } else { if (isset($_GET['active']) && $_GET['active'] == "exception") { } else { if (isset($_GET['active']) && $_GET['active'] == "waittingDeal") { } else { if (isset($_GET['active']) && $_GET['active'] == "alterArea") { $id = $_GET['id']; $strSql = "select f_province,f_city,f_area,f_name from t_area where f_id = '{$id}'"; $rs = DbOperator::queryAll($strSql); echo json_encode($rs, JSON_UNESCAPED_UNICODE); } else { if (isset($_POST['submit']) && $_POST['func'] == "update") { $arrayBean = array($_POST['province3'], $_POST['city3'], $_POST['area3'], $_POST['address'], $_POST['id']); $bRet = Area::updateInfo($arrayBean); if ($bRet == true) { $areaBean = Area::getAllAreaRecord(); $smarty->assign("areaBean", $areaBean); $smarty->display('area.html'); } else { echo "<script>alert('修改失败');history.back();</script>"; } } else { if (isset($_POST['submit']) && empty($_POST['id'])) { if ($_POST['province3'] != "" && $_POST['city3'] != "" && $_POST['area3'] != "") {
public static function getAllCollector() { try { $strSql = "select t_collector.f_id,t_collector.f_code,t_collector.f_name,t2.f_name as f_area,t1.f_name as f_road,t_collector.f_address,t_collector.f_ip,t_users.f_fullname as f_user,t_collector.f_status,t_collector.f_time from t_collector join t_area t1 on t1.f_id=t_collector.f_road join t_area t2 on t2.f_id=t_collector.f_area join t_users on t_users.f_id=t_collector.f_user order by t_collector.f_id"; $rs = DbOperator::queryAll($strSql); $count = 0; foreach ($rs as $arrayIndex) { $collector = new Collector(); $collector->id = 1 + $count; $collector->code = sprintf("%08X", (double) $arrayIndex['F_CODE']); $collector->name = $arrayIndex['F_NAME']; $collector->area = $arrayIndex['F_AREA']; $collector->road = $arrayIndex['F_ROAD']; $collector->address = $arrayIndex['F_ADDRESS']; $collector->ip = $arrayIndex['F_IP']; $collector->user = $arrayIndex['F_USER']; if ($arrayIndex['F_STATUS'] == 0) { $collector->status = "<strong style = 'color:red'>禁用</strong>"; } else { if ($arrayIndex['F_STATUS'] == 1) { $collector->status = "<strong style = 'color:blue'>禁用</strong>"; } } $collector->time = $arrayIndex['F_TIME']; self::$beanArray[$count++] = $collector; } } catch (Exception $e) { print "Error: " . $e->getMessage() . "<br/>"; die; } }
public static function getBoxPos() { try { $strSql = "select f_user,f_code,f_address,f_longitude,f_latitude from t_box"; $rs = DbOperator::queryAll($strSql); return $rs; } catch (Exception $e) { print "Error: " . $e->getMessage() . "<br/>"; die; } }
public static function deleteAreaById($id) { try { $strSql = "delete from t_area where f_id=?"; $bRet = DbOperator::executeArraySql($strSql, array(array($id))); return $bRet; } catch (Exception $e) { print "Error: " . $e->getMessage() . "<br/>"; die; } }
public static function addRank($arrayBean) { try { $insertSql = "insert into t_rank(f_type,f_title,f_desc,f_time)values(?,?,?,?)"; $bRet = DbOperator::executeArraySql($insertSql, array($arrayBean)); return $bRet; } catch (Exception $e) { print "Error: " . $e->getMessage() . "<br/>"; die; } return $rs; }
public static function getHistoryDeal() { $strSql = "select t_data.f_code,t1.f_name as f_area,t2.f_name as f_road,t_data.f_address,t_data.f_name,t3.f_fullname as f_owner,t4.f_fullname as f_worker,t_data.f_open_time,t_data.f_close_time,t_data.f_create_time,t5.f_title as f_sel_worker,t6.f_title as f_sel_owner from t_data join t_area t1 on t1.f_id=t_data.f_area join t_area t2 on t2.f_id=t_data.f_road left join t_users t3 on t3.f_id=t_data.f_owner left join t_users t4 on t4.f_id=t_data.f_worker left join t_rank t5 on t5.f_id=t_data.f_sel_worker left join t_rank t6 on t6.f_id=t_data.f_sel_owner where 1 order by t_data.f_id desc"; $rs = DbOperator::queryAll($strSql); $beanArray = array(); $count = 0; if (!empty($rs)) { foreach ($rs as $arrayIndex) { $dataDetails = new DataDetails(); $dataDetails->id = 1 + $count; $dataDetails->code = $arrayIndex['F_CODE']; $dataDetails->area = $arrayIndex['F_AREA']; $dataDetails->road = $arrayIndex['F_ROAD']; $dataDetails->address = $arrayIndex['F_ADDRESS']; $dataDetails->name = $arrayIndex['F_NAME']; if (empty($arrayIndex['F_OWNER'])) { $dataDetails->owner = "未知"; } else { $dataDetails->owner = $arrayIndex['F_OWNER']; } if (empty($arrayIndex['F_WORKER'])) { $dataDetails->worker = "未知"; } else { $dataDetails->worker = $arrayIndex['F_WORKER']; } $dataDetails->openTime = $arrayIndex['F_OPEN_TIME']; if (empty($arrayIndex['F_CLOSE_TIME'])) { $dataDetails->closeTime = "尚未关闭"; } else { $dataDetails->closeTime = $arrayIndex['F_CLOSE_TIME']; } if (empty($arrayIndex['F_SEL_WORKER'])) { $dataDetails->selWorker = "尚未处理"; } else { $dataDetails->selWorker = $arrayIndex['F_SEL_WORKER']; } if (empty($arrayIndex['F_SEL_OWNER'])) { $dataDetails->selOwner = "尚未处理"; } else { $dataDetails->selOwner = $arrayIndex['F_SEL_OWNER']; } $dataDetails->createTime = $arrayIndex['F_CREATE_TIME']; $beanArray[$count++] = $dataDetails; } return $beanArray; } else { return null; } }
public static function getHead() { try { $strSql = "select f_id,f_fullname,f_phone,f_boss,f_time from t_head where f_boss > 0"; $rs = DbOperator::queryAll($strSql); $count = 0; $beanArray = array(); foreach ($rs as $arrayIndex) { $head = new Head(); $head->id = $arrayIndex['F_ID']; $head->fullName = $arrayIndex['F_FULLNAME']; $head->phone = $arrayIndex['F_PHONE']; $head->time = $arrayIndex['F_TIME']; $head->boss = $arrayIndex['F_BOSS']; $beanArray[$count++] = $head; } return $beanArray; } catch (Exception $e) { print "Error: " . $e->getMessage() . "<br/>"; die; } }
* *@file ajax.php *@author xieyoujiang *@data 2016年1月30日 *@language PHP *@e-mail xie_youjiang@163.com *@copyright(c) 扬州格佳科技有限公司 * */ require_once './classpackage/Db.class.php'; if (isset($_GET['id'])) { $strUserSql = "select f_id,f_username,f_password,f_fullname,f_phone,f_rank,f_head,f_head_phone,f_boss_phone,f_time,f_last_login,f_last_ip,f_last_time from t_users where f_id = ?"; $strRankSql = "select f_id,f_title from t_rank where f_type=1"; $strBossSql = "select f_id,f_fullname from t_head where f_boss>0"; $rsUser = DbOperator::querySql($strUserSql, array($_GET['id'])); $rsRank = DbOperator::queryAll($strRankSql); $rsBoss = DbOperator::queryAll($strBossSql); $rsUser['rank'] = $rsRank; $rsUser['boss'] = $rsBoss; echo json_encode($rsUser, JSON_UNESCAPED_UNICODE); } else { if (isset($_GET['active']) && $_GET['active'] == "addStaff") { $strRankSql = "select f_id,f_title from t_rank where f_type=1"; $strBossSql = "select f_id,f_fullname from t_head where f_boss>0"; $rsRank = DbOperator::queryAll($strRankSql); $rsBoss = DbOperator::queryAll($strBossSql); $rs['rank'] = $rsRank; $rs['boss'] = $rsBoss; echo json_encode($rs, JSON_UNESCAPED_UNICODE); } }
} else { if (isset($_GET['active']) && $_GET['active'] == "addBox") { $area = Area::getAreaInfo(); $road = Area::getRoadInfo(); $user = User::getUserInfo(); $handle = @fopen("./version.txt", "r"); if ($handle) { while (!feof($handle)) { $buffer = fgets($handle, 4096); $version[] = $buffer; } fclose($handle); } try { $querySql = "SELECT max( f_id ) AS max FROM t_box"; $max = DbOperator::queryAll($querySql); } catch (Exception $e) { print "Error: " . $e->getMessage() . "<br/>"; die; } $rs['code'] = sprintf("%08d", 1 + $max[0]['MAX']); $rs['area'] = $area; $rs['road'] = $road; $rs['user'] = $user; $rs['version'] = $version; echo json_encode($rs, JSON_UNESCAPED_UNICODE); } else { if (isset($_POST['submit']) && empty($_POST['id'])) { $preCode = $_POST['preName']; $midCode = $_POST['code']; $version = $_POST['version'];
public static function getByName($userName) { try { $strSql = "select f_rank, f_fullname from t_users where f_username= '******'"; $bRet = DbOperator::querySql($strSql); return $bRet; } catch (Exception $e) { print "Error: " . $e->getMessage() . "<br/>"; die; } }