#include <MysqlResults.h>
Inheritance diagram for rdbModel::MysqlResults:
Public Member Functions | |
virtual | ~MysqlResults () |
virtual unsigned int | getNRows () const |
Return number of rows in results. | |
virtual bool | getRow (std::vector< std::string > &fields, unsigned int i=0, bool clear=true) |
virtual bool | getRowPtrs (std::vector< std::string * > &fieldPtrs, unsigned int i=0, bool clear=true) |
virtual bool | getRowCon (char *par, unsigned long *treesize, unsigned int *runFrm, unsigned int *runTo, unsigned int i=0, bool clear=true) |
Static Public Member Functions | |
static void | cleanFieldPtrs (std::vector< std::string * > &fields) |
Private Member Functions | |
MysqlResults (MYSQL_RES *results=0) | |
Private Attributes | |
MYSQL_RES * | m_myres |
Friends | |
class | MysqlConnection |
Definition at line 16 of file MysqlResults.h.
rdbModel::MysqlResults::~MysqlResults | ( | ) | [virtual] |
Definition at line 17 of file MysqlResults.cxx.
References m_myres.
00017 { 00018 mysql_free_result(m_myres); 00019 }
rdbModel::MysqlResults::MysqlResults | ( | MYSQL_RES * | results = 0 |
) | [private] |
void rdbModel::ResultHandle::cleanFieldPtrs | ( | std::vector< std::string * > & | fields | ) | [static, inherited] |
Definition at line 7 of file ResultHandle.cxx.
References genRecEmupikp::i.
Referenced by rdbModel::Table::supersedeRow().
00007 { 00008 for (unsigned i = 0; i < fields.size(); i++) { 00009 if (fields[i] != 0) delete fields[i]; 00010 } 00011 fields.resize(0); 00012 }
unsigned int rdbModel::MysqlResults::getNRows | ( | ) | const [virtual] |
Return number of rows in results.
Implements rdbModel::ResultHandle.
Definition at line 21 of file MysqlResults.cxx.
References m_myres.
00021 { 00022 return mysql_num_rows(m_myres); 00023 }
bool rdbModel::MysqlResults::getRow | ( | std::vector< std::string > & | fields, | |
unsigned int | i = 0 , |
|||
bool | clear = true | |||
) | [virtual] |
Get array of field values for ith row of result set
Implements rdbModel::ResultHandle.
Definition at line 25 of file MysqlResults.cxx.
References m_myres, and deljobs::string.
00026 { 00027 mysql_data_seek(m_myres, i); 00028 MYSQL_ROW myRow = mysql_fetch_row(m_myres); 00029 00030 unsigned nFields = mysql_num_fields(m_myres); 00031 00032 00033 if (clear) fields.clear(); 00034 00035 for (unsigned int iField = 0; iField < nFields; iField++) { 00036 if (myRow[iField]) fields.push_back(std::string(myRow[iField])); 00037 else fields.push_back(""); 00038 } 00039 00040 return true; 00041 }
bool rdbModel::MysqlResults::getRowCon | ( | char * | par, | |
unsigned long * | treesize, | |||
unsigned int * | runFrm, | |||
unsigned int * | runTo, | |||
unsigned int | i = 0 , |
|||
bool | clear = true | |||
) | [virtual] |
Implements rdbModel::ResultHandle.
Definition at line 64 of file MysqlResults.cxx.
References m_myres.
00065 { 00066 mysql_data_seek(m_myres, i); 00067 MYSQL_ROW myRow = mysql_fetch_row(m_myres); 00068 unsigned nFields = mysql_num_fields(m_myres); 00069 unsigned long* lengths; 00070 lengths = mysql_fetch_lengths(m_myres); 00071 00072 for (unsigned int iField = 0; iField <nFields; iField++) { 00073 if (myRow[iField]&&iField<(nFields-4)){ 00074 memcpy(par+1024000*iField,myRow[iField],lengths[iField]); 00075 treesize[iField] = lengths[iField]; 00076 } 00077 } 00078 00079 *runFrm =facilities::Util::stringToInt(myRow[nFields-4]); 00080 *runTo =facilities::Util::stringToInt(myRow[nFields-3]); 00081 std::cout<<" CalVerSft is "<<myRow[nFields-2]<<" File name is "<<myRow[nFields-1]<<std::endl; 00082 00083 return true; 00084 00085 }
bool rdbModel::MysqlResults::getRowPtrs | ( | std::vector< std::string * > & | fieldPtrs, | |
unsigned int | i = 0 , |
|||
bool | clear = true | |||
) | [virtual] |
Get array of field values for ith row of result set. If a field value is NULL, return a zero ptr for that element of the array.
--> It is the responsibility of the caller to delete the strings containing the field values. See service cleanFieldPtrs in base class ResultHandle.
Implements rdbModel::ResultHandle.
Definition at line 43 of file MysqlResults.cxx.
References m_myres, and deljobs::string.
00044 { 00045 00046 mysql_data_seek(m_myres, i); 00047 MYSQL_ROW myRow = mysql_fetch_row(m_myres); 00048 00049 unsigned nFields = mysql_num_fields(m_myres); 00050 00051 00052 if (clear) fields.clear(); 00053 00054 for (unsigned int iField = 0; iField < nFields; iField++) { 00055 if (myRow[iField]) fields.push_back(new std::string(myRow[iField])); 00056 else fields.push_back(0); 00057 } 00058 00059 return true; 00060 00061 }
friend class MysqlConnection [friend] |
Definition at line 17 of file MysqlResults.h.
MYSQL_RES* rdbModel::MysqlResults::m_myres [private] |
Definition at line 64 of file MysqlResults.h.
Referenced by getNRows(), getRow(), getRowCon(), getRowPtrs(), and ~MysqlResults().