1
Player.find_by_sql(["SELECT u.id, u.name, UNIX_TIMESTAMP(u.last_active) AS last_active, TIME_TO_SEC(TIMEDIFF(NOW(), u.last_active)) AS time_difference, r.status, SUM(d.amount) AS gold_spent, SUM(d2.amount) AS points_spent
FROM players u
LEFT JOIN guild_ranks r ON r.player_id=u.id AND r.guild_id=u.guild_id
LEFT JOIN guild_donations d ON d.player_id=u.id AND d.guild_id=u.guild_id AND d.type=1
LEFT JOIN guild_donations d2 ON d2.player_id=u.id AND d2.guild_id=u.guild_id AND d2.type=2
WHERE u.guild_id=? ORDER BY r.status, u.level DESC", guild]

返された DataMapper::Collection に、time_difference だけでなく、gold_spent と points_spent も含めるにはどうすればよいですか?

gold_spent、points_spent、および time_difference はプロパティであってはなりません(または、データベース内ではなく単なる DM プロパティになるようにする方法はありますか?)

4

0 に答える 0