The Mysql2
documentation is indeed very poor. But by inspecting the type of results
you will notice that it is a Mysql2::Result
which contains 3 methods. The one that you are interested in is count
(or alias size
) which will return the number of rows of the result.
From here you can easily check if it is 0
:
(results.count == 0)
Alternatively you could open the Mysql2::Result
class and add the method empty?
yourself:
class Mysql2::Result
def empty?
(count == 0)
end
end
And then you can just do:
results.empty?