版本更新至:3.827

修复:MySQLConnection 排序失效问题
This commit is contained in:
坏黑 2018-03-27 21:28:19 +08:00
parent 6d5205a3bd
commit 890601bacb
2 changed files with 7 additions and 9 deletions

View File

@ -6,7 +6,7 @@ website: http://www.15imc.com/index.html
main: me.skymc.taboolib.Main main: me.skymc.taboolib.Main
version: 3.826 version: 3.827
commands: commands:
taboolib: taboolib:

View File

@ -49,8 +49,8 @@ public class MySQLConnection {
} }
// 设置信息 // 设置信息
this.plugin = plugin; // this.plugin = plugin;
this.recheck = recheck; // this.recheck = recheck;
// 设置数据 // 设置数据
this.url = url == null ? "localhost" : url; this.url = url == null ? "localhost" : url;
@ -581,11 +581,10 @@ public class MySQLConnection {
ResultSet resultSet = null; ResultSet resultSet = null;
try { try {
if (desc) { if (desc) {
pstmt = connection.prepareStatement("select * from `" + name + "` order by ? desc " + (size < 0 ? "" : " limit " + size)); pstmt = connection.prepareStatement("select * from `" + name + "` order by `" + column + "` desc " + (size < 0 ? "" : " limit " + size));
} else { } else {
pstmt = connection.prepareStatement("select * from `" + name + "` order by ? " + (size < 0 ? "" : " limit " + size)); pstmt = connection.prepareStatement("select * from `" + name + "` order by `" + column + "` " + (size < 0 ? "" : " limit " + size));
} }
pstmt.setString(1, column);
resultSet = pstmt.executeQuery(); resultSet = pstmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
list.add(resultSet.getObject(column)); list.add(resultSet.getObject(column));
@ -632,11 +631,10 @@ public class MySQLConnection {
ResultSet resultSet = null; ResultSet resultSet = null;
try { try {
if (desc) { if (desc) {
pstmt = connection.prepareStatement("select * from `" + name + "` order by ? desc " + (size < 0 ? "" : " limit " + size)); pstmt = connection.prepareStatement("select * from `" + name + "` order by `" + sortColumn + "` desc" + (size < 0 ? "" : " limit " + size));
} else { } else {
pstmt = connection.prepareStatement("select * from `" + name + "` order by ? " + (size < 0 ? "" : " limit " + size)); pstmt = connection.prepareStatement("select * from `" + name + "` order by `" + sortColumn + "`" + (size < 0 ? "" : " limit " + size));
} }
pstmt.setString(1, sortColumn);
resultSet = pstmt.executeQuery(); resultSet = pstmt.executeQuery();
while (resultSet.next()) { while (resultSet.next()) {
HashMap<String, Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();