ROOT logo
// @(#)root/mysql:$Id: TMySQLRow.cxx 20882 2007-11-19 11:31:26Z rdm $
// Author: Fons Rademakers   15/02/2000

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "TMySQLRow.h"


ClassImp(TMySQLRow)

//______________________________________________________________________________
TMySQLRow::TMySQLRow(void *res, ULong_t rowHandle)
{
   // Single row of query result.

   fResult      = (MYSQL_RES *) res;
   fFields      = (MYSQL_ROW) rowHandle;
   fFieldLength = 0;
}

//______________________________________________________________________________
TMySQLRow::~TMySQLRow()
{
   // Destroy row object.

   if (fFields)
      Close();
}

//______________________________________________________________________________
void TMySQLRow::Close(Option_t *)
{
   // Close row.
   
   if (!fFields)
      return;

   fFields      = 0;
   fResult      = 0;
   fFieldLength = 0;
}

//______________________________________________________________________________
Bool_t TMySQLRow::IsValid(Int_t field)
{
   // Check if row is open and field index within range.
   
   if (!fFields) {
      Error("IsValid", "row closed");
      return kFALSE;
   }
   if (field < 0 || field >= (Int_t)mysql_num_fields(fResult)) {
      Error("IsValid", "field index out of bounds");
      return kFALSE;
   }
   return kTRUE;
}

//______________________________________________________________________________
ULong_t TMySQLRow::GetFieldLength(Int_t field)
{
   // Get length in bytes of specified field.
   
   if (!IsValid(field))
      return 0;

   if (!fFieldLength)
      fFieldLength = mysql_fetch_lengths(fResult);
   
   if (!fFieldLength) {
      Error("GetFieldLength", "cannot get field length");
      return 0;
   }

   return fFieldLength[field];
}

//______________________________________________________________________________
const char *TMySQLRow::GetField(Int_t field)
{
   // Get specified field from row (0 <= field < GetFieldCount()).

   if (!IsValid(field))
      return 0;

   return fFields[field];
}
 TMySQLRow.cxx:1
 TMySQLRow.cxx:2
 TMySQLRow.cxx:3
 TMySQLRow.cxx:4
 TMySQLRow.cxx:5
 TMySQLRow.cxx:6
 TMySQLRow.cxx:7
 TMySQLRow.cxx:8
 TMySQLRow.cxx:9
 TMySQLRow.cxx:10
 TMySQLRow.cxx:11
 TMySQLRow.cxx:12
 TMySQLRow.cxx:13
 TMySQLRow.cxx:14
 TMySQLRow.cxx:15
 TMySQLRow.cxx:16
 TMySQLRow.cxx:17
 TMySQLRow.cxx:18
 TMySQLRow.cxx:19
 TMySQLRow.cxx:20
 TMySQLRow.cxx:21
 TMySQLRow.cxx:22
 TMySQLRow.cxx:23
 TMySQLRow.cxx:24
 TMySQLRow.cxx:25
 TMySQLRow.cxx:26
 TMySQLRow.cxx:27
 TMySQLRow.cxx:28
 TMySQLRow.cxx:29
 TMySQLRow.cxx:30
 TMySQLRow.cxx:31
 TMySQLRow.cxx:32
 TMySQLRow.cxx:33
 TMySQLRow.cxx:34
 TMySQLRow.cxx:35
 TMySQLRow.cxx:36
 TMySQLRow.cxx:37
 TMySQLRow.cxx:38
 TMySQLRow.cxx:39
 TMySQLRow.cxx:40
 TMySQLRow.cxx:41
 TMySQLRow.cxx:42
 TMySQLRow.cxx:43
 TMySQLRow.cxx:44
 TMySQLRow.cxx:45
 TMySQLRow.cxx:46
 TMySQLRow.cxx:47
 TMySQLRow.cxx:48
 TMySQLRow.cxx:49
 TMySQLRow.cxx:50
 TMySQLRow.cxx:51
 TMySQLRow.cxx:52
 TMySQLRow.cxx:53
 TMySQLRow.cxx:54
 TMySQLRow.cxx:55
 TMySQLRow.cxx:56
 TMySQLRow.cxx:57
 TMySQLRow.cxx:58
 TMySQLRow.cxx:59
 TMySQLRow.cxx:60
 TMySQLRow.cxx:61
 TMySQLRow.cxx:62
 TMySQLRow.cxx:63
 TMySQLRow.cxx:64
 TMySQLRow.cxx:65
 TMySQLRow.cxx:66
 TMySQLRow.cxx:67
 TMySQLRow.cxx:68
 TMySQLRow.cxx:69
 TMySQLRow.cxx:70
 TMySQLRow.cxx:71
 TMySQLRow.cxx:72
 TMySQLRow.cxx:73
 TMySQLRow.cxx:74
 TMySQLRow.cxx:75
 TMySQLRow.cxx:76
 TMySQLRow.cxx:77
 TMySQLRow.cxx:78
 TMySQLRow.cxx:79
 TMySQLRow.cxx:80
 TMySQLRow.cxx:81
 TMySQLRow.cxx:82
 TMySQLRow.cxx:83
 TMySQLRow.cxx:84
 TMySQLRow.cxx:85
 TMySQLRow.cxx:86
 TMySQLRow.cxx:87
 TMySQLRow.cxx:88
 TMySQLRow.cxx:89
 TMySQLRow.cxx:90
 TMySQLRow.cxx:91
 TMySQLRow.cxx:92
 TMySQLRow.cxx:93