public static boolean addFood(String string,String photoUrl,String PhotoId) {
		Connection conn = ConnectionFactory.getConnection();
		PreparedStatement pst = null;

		int i = 0;
		// 用来判断创建菜品时是否包含了食堂或者类型
		String canteenString = ",f_canteen";
		String typeString = ",f_type";
		String haveCanteen = ",?";
		String haveType = ",?";
		// 根据参数的json得到food对象
		Food food = JsonUtils.getFoodByJson(string);

		food.setPhoto(photoUrl);
		food.setId(PhotoId);
		
		if (food.getCanteen().equals("")) {
			canteenString = "";
			haveCanteen = "";
		}
		if (food.getType().equals("")) {
			typeString = "";
			haveType = "";
		}

		String sql = "insert into food_menu (f_id,f_name,f_username,f_photo,f_school,f_price"
				+ canteenString
				+ typeString
				+ ") values (?,?,?,?,?,?"
				+ haveCanteen + haveType + ");";

		try {
			pst = conn.prepareStatement(sql);

			pst.setString(1, food.getId());
			pst.setString(2, food.getName());
			pst.setString(3, food.getUserName());
			pst.setString(4, food.getPhoto());
			pst.setString(5, food.getSchool());
			pst.setFloat(6, food.getPrice());

			if (!canteenString.equals("") && !typeString.equals("")) {
				pst.setString(7, food.getCanteen());
				pst.setString(8, food.getType());
			} else if (!canteenString.equals("")) {
				pst.setString(7, food.getCanteen());
			} else if (!typeString.equals("")) {
				pst.setString(7, food.getType());
			}

			pst.executeUpdate();
			i = 1;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			ConnectionFactory.close(null, pst, conn);
		}
		return i == 1 ? true : false;
	}