#include "TMySQLResult.h"
#include "TMySQLRow.h"
ClassImp(TMySQLResult)
TMySQLResult::TMySQLResult(void *result)
{
   
   
   fResult    = (MYSQL_RES *) result;
   fRowCount  = fResult ? mysql_num_rows(fResult) : 0;
   fFieldInfo = 0;
}
TMySQLResult::~TMySQLResult()
{
   
   if (fResult)
      Close();
}
void TMySQLResult::Close(Option_t *)
{
   
   if (!fResult)
      return;
   mysql_free_result(fResult);
   fResult    = 0;
   fFieldInfo = 0;
   fRowCount  = 0;
}
Bool_t TMySQLResult::IsValid(Int_t field)
{
   
   
   if (!fResult) {
      Error("IsValid", "result set closed");
      return kFALSE;
   }
   if (field < 0 || field >= GetFieldCount()) {
      Error("IsValid", "field index out of bounds");
      return kFALSE;
   }
   return kTRUE;
}
Int_t TMySQLResult::GetFieldCount()
{
   
   
   if (!fResult) {
      Error("GetFieldCount", "result set closed");
      return 0;
   }
   return mysql_num_fields(fResult);
}
const char *TMySQLResult::GetFieldName(Int_t field)
{
   
   
   if (!IsValid(field))
      return 0;
   if (!fFieldInfo)
      fFieldInfo = mysql_fetch_fields(fResult);
   
   if (!fFieldInfo) {
      Error("GetFieldName", "cannot get field info");
      return 0;
   }
   return fFieldInfo[field].name;
}
TSQLRow *TMySQLResult::Next()
{
   
   
   MYSQL_ROW row;
    
   if (!fResult) {
      Error("Next", "result set closed");
      return 0;
   }
   row = mysql_fetch_row(fResult);
   if (!row)
      return 0;
   else
      return new TMySQLRow((void *) fResult, (ULong_t) row);
}
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.