Row count

Hi All

I’m trying to make sure I capture any arrors when getting data returned from my database, I assumed rowCount was what I was after but this generates an error, can anyone tell me why please

$records = ir_db_query($table, $arg);
   if (function_exists('ir_db_insert')) {
     if(!records){
       drupal_set_message(t('Something went wrong'), 'error');
     }
     elseif ($records->rowCount() > 0){

// code if more than 0 rows returned....

}
      else
      {
       drupal_set_message(t('Something went wrong'), 'error');   
      }
   } 

Many Thanks

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/4/feed