new classes that were automatically generated from mysql tables
[u/mrichter/AliRoot.git] / PHOS / AliDBPPRS.cxx
CommitLineData
ba230b91 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18//_________________________________________________________________________
19// DB Class for table PPRS:
20//
21//*-- Author: Yves Schutz (SUBATECH)
22//////////////////////////////////////////////////////////////////////////////
23
24#include <stdlib.h>
25#include <iostream.h>
26
27// --- ROOT system ---
28#include "TSQLServer.h"
29#include "TSQLRow.h"
30#include "TSQLResult.h"
31#include "TDatime.h"
32
33// --- Standard library ---
34
35// --- AliRoot header files ---
36#include "AliDBPPRS.h"
37
38ClassImp(AliDBPPRS)
39//____________________________________________________________________________
40AliDBPPRS::AliDBPPRS()
41{
42 fCurrentEntry = 1 ; // first valid entry (0 = labels)
43 fNfields = 12 ;
44 fFields = new TString[12];
45 fFields[0] = "RUN";
46 fFields[1] = "EVENT";
47 fFields[2] = "WORKER";
48 fFields[3] = "STATUS";
49 fFields[4] = "DATE";
50 fFields[5] = "STORAGE";
51 fFields[6] = "ID";
52 fFields[7] = "POS";
53 fFields[8] = "SIZE";
54 fFields[9] = "FTP";
55 fFields[10] = "LOG";
56 fFields[11] = "COMMENT";
57}
58//____________________________________________________________________________
59AliDBPPRS::~AliDBPPRS()
60{
61 delete[] fFields ;
62}
63//____________________________________________________________________________
64void AliDBPPRS::GetEntry(Option_t * opt)
65{
66 // Retrieves one single row from the table // opt = first : retrieves first entry
67 // opt = last : retrieves last entry
68 // opt = next : retrieves next to current entry
69 TSQLServer * mysql = TSQLServer::Connect("mysql://ccmysql.in2p3.fr:3306/alice", "schutz", "po2hgwy") ;
70 TSQLResult * result = mysql->Query("SELECT * FROM PPRS") ;
71 Int_t count = result->GetRowCount() ;
72 if ( !strcmp(opt, "first") ) fCurrentEntry = 1 ;
73 if ( !strcmp(opt, "last") ) fCurrentEntry = count ;
74 if ( fCurrentEntry > count ) fCurrentEntry = 1 ;
75 Int_t i;
76 Int_t end = fCurrentEntry ;
77 TSQLRow * row = 0 ;
78 for ( i = 0 ; i < end ; i++ ) {
79 fCurrentEntry++ ;
80 row = result->Next() ;
81 }
82 fRUN = atoi(row->GetField(0)) ;
83 fEVENT = atoi(row->GetField(1)) ;
84 fWORKER = row->GetField(2) ;
85 fSTATUS = row->GetField(3) ;
86 fDATE = TDatime::TDatime(row->GetField(4)) ;
87 fSTORAGE = row->GetField(5) ;
88 fID = row->GetField(6) ;
89 fPOS = atoi(row->GetField(7)) ;
90 fSIZE = atoi(row->GetField(8)) ;
91 fFTP = row->GetField(9) ;
92 fLOG = row->GetField(10) ;
93 fCOMMENT = row->GetField(11) ;
94}