⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 msqlquery.h

📁 C++连接一写常用数据库的接口
💻 H
字号:
/* * MsqlQuery object defines the needed query functions for the dbConnect mSQL driver * Copyright (C) 2003 Johnathan Ingram, jingram@rogue-order.net * * This library is free software; you can redistribute it and/or *   modify it under the terms of the GNU Lesser General Public *   License as published by the Free Software Foundation; either *   version 2.1 of the License, or (at your option) any later version. * *   This library is distributed in the hope that it will be useful, *   but WITHOUT ANY WARRANTY; without even the implied warranty of *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *   Lesser General Public License for more details. * *   You should have received a copy of the GNU Lesser General Public *   License along with this library; if not, write to the Free Software *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  US * */#ifndef __MSQL_QUERY_H__#define __MSQL_QUERY_H__#include <string>#include "baseQuery.h"#include "baseFieldDescription.h"#include "baseValue.h"#include "msqlConnection.h"#include "msqlBindParam.h"#include "simpleThreads.h"#include <msql.h>using namespace std;class MsqlQuery : public BaseQuery{private:        // Collection types that can be freed within this object   enum CollectionType   {      FIELD_INFORMATION,      FIELD_VALUES,      BIND_PARAMETERS   };         // Msql Handles   m_result         *_result;   DBULONG          _msqlNumRows;   DBULONG          _msqlCurrentRow;   // Parameter collection.   DBULONG         _numParameters;   MsqlBindParam **_parameters;   // Field Information collection   DBULONG                _numFieldInformation;   BaseFieldDescription **_fieldInformation;   // Field Value collection   DBULONG     _numRecordValues;   BaseValue **_recordValues;     MsqlConnection* _parentConnection;      int             _index;            // Index of the handle object   /* Internal method to obtain the information     *   about the fields returned in a result set.    */   void   _msqlGetFieldsInformation();   /* Internal method to obtain the data in the result set row    */   void   _msqlGetResultSetRow();   /* Internal method to return the dbConnect type for the mSQL field    *    * @param type    The mSQL field type to resolve to a dbConnect field type    *    * @return   Returns the dbConnect field type for the given mSQL field type    */   FieldType   _msqlResolveFieldType(      int type);    /* Internal method to parse the parameters that need to be bound in the SQL query    *    * @param originalSqlStatement  The sql statement with the bind parameters.    *    * @return   Returns the parsed SQL that can be executed by MySQL    */   string   _msqlParseBindParameters(         const string& originalSqlStatement);   /* Internal method to free internally allocated memory    *    * @param type    The type representing which value to deallocate.    *    */   void _freeCollection(      CollectionType type);public:   /* Constructor.    *    */   MsqlQuery(      MsqlConnection* parentConnection,      int              index);   /* Destructor.    *    */   virtual    ~MsqlQuery();         /* Clears any bind parameters    *    */   void    clearBindParams();   /* Set the SQL / DDL command that will be used for bind     *  paramaters and the execute    *    * @param sqlStatement  Statement wanting to execute    *    */   void   command(      const string& sqlStatement);   /* Set the value for a parameter giving the parameter name.    *    * @param paramName      Name of the parameter.    *    * @return               Returns the parameter object for the position.    */   BaseValue*   bindParam(      const string& paramName);    /* Execute the sql statement set by command    *    */   void   execute();   /* Obtain the next row of data in the record set.    *    */   void   fetchNext();   /* Begin a transaction.    * Make virtual so a new driver can inherit and implement    *    */   virtual void   transBegin();         /* Commit a transaction.    * Make virtual so a new driver can inherit and implement    *    */   virtual void   commit();         /* Rollback a transaction.    * Make virtual so a new driver can inherit and implement    *    */   virtual void   rollback();      /* Returns the information about a field.    *    * @param    index     Index of the field.    *    * @return             Returns a pointer to the field information structure.    */   BaseFieldDescription*   getFieldInfoByColumn(      int index);   /* Returns the information about a field.    *    * @param    fieldName Name of the field.    *    * @return             Returns a pointer to the field information structure.    */   BaseFieldDescription*   getFieldInfoByName(      const string& fieldName);            /* Returns the value of a field.    *    * @param    index     Index of the field.    *    * @return   Returns a pointer to the value structure.    */   BaseValue*   getFieldByColumn(      int index);   /* Returns the value of a field.    *    * @param    fieldName Name of the field.    *    * @return   Returns a pointer to the value structure.    */   BaseValue*   getFieldByName(      const string& fieldName);      };#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -