getLimitSql was returning the wrong value for limit $limit