Refactoring of this complex PHP method
Don't know what happens in your db, but LIMIT 1 suggests that result of your query will return exactly what you ask or nothing. In this case no need to compare caller and opponent in if statement - just return (false) from method when $last is empty/false.

Otherwise if one caller may have more 'winner = 0' opponents LIMIT 1 could give you result that you won't use (if statement will reject it) while there's a valid one but was cut off by limit. In this case better provide full description in where clause (if statement will also check if there is any result).