DataMapper and find_by_sql problem
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 开发者_JAVA技巧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]
How can I get the returned DataMapper::Collection to also include gold_spent and points_spent as well as time_difference?
gold_spent, points_spent, and time_difference should not be properties (or is there a way to make it so they're just DM properties and not within the database?)
精彩评论