Main Page   Data Structures   File List   Data Fields  

MyMySQLPPResult.cpp

Go to the documentation of this file.
00001 /*
00002         MyMySQL++ - Another MySQL++ API providing basic and easy access to MySQL functionality.
00003     Copyright (C) 2003 Stefan Schadt
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00029 #include "pch.h"
00030 #include "MyMySQLPPResult.h"
00031 
00033 CMyMySQLPPResult::CMyMySQLPPResult(void)
00034 {
00035         m_res = NULL;
00036 }
00037 
00039 CMyMySQLPPResult::~CMyMySQLPPResult(void)
00040 {
00041         Free();
00042 }
00043 
00045 void CMyMySQLPPResult::Free(void)
00046 {
00047         if(m_res != NULL)
00048                 mysql_free_result(m_res);
00049         m_res = NULL;
00050 }
00051 
00055 MYSQL_RES* CMyMySQLPPResult::Detach(void)
00056 {
00057         return m_res;
00058         m_res = NULL;
00059 }
00060 
00064 void CMyMySQLPPResult::Attach(MYSQL_RES* Result)
00065 {
00066         Free();
00067         m_res = Result;
00068 }
00069 
00073 MYSQL_ROW_OFFSET CMyMySQLPPResult::RowTell(void)
00074 {
00075         if(m_res == NULL)
00076                 return NULL;
00077         return mysql_row_tell(m_res);
00078 }
00079 
00084 MYSQL_ROW_OFFSET CMyMySQLPPResult::RowSeek(MYSQL_ROW_OFFSET Offset)
00085 {
00086         if(m_res == NULL)
00087                 return NULL;
00088         return mysql_row_seek(m_res, Offset);
00089 }
00090 
00094 void CMyMySQLPPResult::DataSeek(__int64 Offset)
00095 {
00096         if(m_res != NULL)
00097                 mysql_data_seek(m_res, Offset);
00098 }
00099 
00103 BOOL CMyMySQLPPResult::EndOfFile(void)
00104 {
00105         if(m_res == NULL)
00106                 return TRUE;
00107         return (mysql_eof(m_res) != 0);
00108 }
00109 
00113 unsigned int CMyMySQLPPResult::NumFields(void)
00114 {
00115         if(m_res == NULL)
00116                 return 0;
00117         return mysql_num_fields(m_res);
00118 }
00119 
00123 __int64 CMyMySQLPPResult::NumRows(void)
00124 {
00125         if(m_res == NULL)
00126                 return 0;
00127         return mysql_num_rows(m_res);
00128 }
00129 
00134 BOOL CMyMySQLPPResult::FetchRow(CMyMySQLPPRow* row)
00135 {
00136         row->Free();
00137         if(m_res == NULL)
00138                 return FALSE;
00139         MYSQL_ROW r = mysql_fetch_row(m_res);
00140         if(r == NULL)
00141                 return FALSE;
00142         row->Attach(r, m_res);
00143         return TRUE;
00144 }
00145 
00149 CMyMySQLPPRow CMyMySQLPPResult::FetchRow(void)
00150 {
00151         if(m_res == NULL)
00152                 return CMyMySQLPPRow();
00153         MYSQL_ROW r = mysql_fetch_row(m_res);
00154         if(r == NULL)
00155                 return CMyMySQLPPRow();
00156         return CMyMySQLPPRow(r, m_res);
00157 }
00158 
00164 BOOL CMyMySQLPPResult::FetchRow(CMyMySQLPPRow* row, __int64 offset)
00165 {
00166         DataSeek(offset);
00167         return FetchRow(row);
00168 }
00169 
00174 CMyMySQLPPRow CMyMySQLPPResult::FetchRow(__int64 offset)
00175 {
00176         DataSeek(offset);
00177         return FetchRow();
00178 }
00179 
00184 CMyMySQLPPRow CMyMySQLPPResult::operator[](__int64 offset)
00185 {
00186         return FetchRow(offset);
00187 }
00188 
00192 unsigned long* CMyMySQLPPResult::FetchLengths(void)
00193 {
00194         if(m_res == NULL)
00195                 return NULL;
00196         return mysql_fetch_lengths(m_res);
00197 }
00198 
00203 BOOL CMyMySQLPPResult::FetchField(CMyMySQLPPField* field)
00204 {
00205         field->Free();
00206         if(m_res == NULL)
00207                 return FALSE;
00208         MYSQL_FIELD *f = mysql_fetch_field(m_res);
00209         if(f == NULL)
00210                 return FALSE;
00211         field->Attach(f);
00212         return TRUE;
00213 }
00214 
00218 CMyMySQLPPField CMyMySQLPPResult::FetchField(void)
00219 {
00220         if(m_res == NULL)
00221                 return CMyMySQLPPField();
00222         MYSQL_FIELD *f = mysql_fetch_field(m_res);
00223         if(f == NULL)
00224                 return CMyMySQLPPField();
00225         return CMyMySQLPPField(f);
00226 }
00227 
00233 BOOL CMyMySQLPPResult::FetchField(CMyMySQLPPField* field, unsigned int fieldnr)
00234 {
00235         field->Free();
00236         if(m_res == NULL)
00237                 return FALSE;
00238         MYSQL_FIELD *f = mysql_fetch_field_direct(m_res, fieldnr);
00239         if(f == NULL)
00240                 return FALSE;
00241         field->Attach(f);
00242         return TRUE;
00243 }
00244 
00249 CMyMySQLPPField CMyMySQLPPResult::FetchField(unsigned int fieldnr)
00250 {
00251         if(m_res == NULL)
00252                 return CMyMySQLPPField();
00253         MYSQL_FIELD *f = mysql_fetch_field_direct(m_res, fieldnr);
00254         if(f == NULL)
00255                 return CMyMySQLPPField();
00256         return CMyMySQLPPField(f);
00257 }
00258 
00263 MYSQL_FIELD_OFFSET CMyMySQLPPResult::FieldSeek(MYSQL_FIELD_OFFSET offset)
00264 {
00265         if(m_res == NULL)
00266                 return NULL;
00267         return mysql_field_seek(m_res, offset);
00268 }
00269 
00273 MYSQL_FIELD_OFFSET CMyMySQLPPResult::FieldTell(void)
00274 {
00275         if(m_res == NULL)
00276                 return NULL;
00277         return mysql_field_tell(m_res);
00278 }

Generated on Thu Feb 20 16:15:50 2003 for MyMySQL++ by doxygen1.3-rc3