24.11.2016, 15:43
Never use num_rows if you merely want a count of something. Use the COUNT() aggregate function instead. Why? In the former case the entire result set is sent. Possibly a few thousand rows. Not efficient. In the latter case the result is always one single field that contains the count.