/** * 插入一条记录 * @para $data as array * return insert_id */ public static function insertRow($data) { self::initDB(); $sql = array2sql($data); $sql = "INSERT INTO `" . self::$table . "` SET " . $sql; $query = self::$dbConn->query($sql); if ($query) { $insertId = self::$dbConn->insert_id(); return $insertId; } else { self::$errCode = "003"; self::$errMsg = "error"; return false; } }
/** * 增加/修改楼层 */ function act_sureAddFloor() { $data = array(); $id = trim($_POST['floorId']); $data['whFloor'] = post_check(trim($_POST['whFloor'])); $data['whCode'] = post_check(trim($_POST['whCode'])); if (empty($id)) { $insertid = FloorModel::insertRow($data); if ($insertid) { return true; } else { return false; } } else { $updatedata = FloorModel::update($data, "and id='{$id}'"); if ($updatedata) { return true; } else { return false; } } }