We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
通过Upsert实现数据表单个数据的改动,避免多次查询。
有些情况下,只需要针对表中单个数据进行增加或减少,且对应的数据并未获取,此时便需要进行获取->修改->写入三个操作,十分不便。
获取->修改->写入
因此,若支持通过Upsert针对该数据进行简单计算的修改,即可大大的增加整体效率。
public void updateStats(long uid, StatsType type, int modify) { if (modify == 0) return; String tableName = DBTables.STATS.getTableName(); getSQLManager().executeSQL( "INSERT INTO " + tableName + "(uid,type,value) " + "VALUE(?,?,?) ON DUPLICATE KEY " + "UPDATE value = value " + (modify > 0 ? "+" : "-") + "?" + " ", new Object[]{uid, type.getID(), Math.abs(modify)} ); }
The text was updated successfully, but these errors were encountered:
CarmJos
No branches or pull requests
功能简述
通过Upsert实现数据表单个数据的改动,避免多次查询。
需求来源
有些情况下,只需要针对表中单个数据进行增加或减少,且对应的数据并未获取,此时便需要进行
获取->修改->写入
三个操作,十分不便。因此,若支持通过Upsert针对该数据进行简单计算的修改,即可大大的增加整体效率。
功能参考(可选)
The text was updated successfully, but these errors were encountered: