📄 mysqlquery.h
字号:
/* * MysqQuery object defines the needed query functions for the dbConnect MySQL driver * Copyright (C) 2002 Johnathan Ingram, jingram@rogueware.org * * 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 __MYSQL_QUERY_H__#define __MYSQL_QUERY_H__#include <string>#include "baseQuery.h"#include "baseFieldDescription.h"#include "mysqlConnection.h"#include "mysqlBindParam.h"#include "mysqlValue.h"#include <mysql.h>using namespace std;class MysqlQuery : public BaseQuery{private: // Collection types that can be freed within this object enum CollectionType { FIELD_INFORMATION, FIELD_VALUES, BIND_PARAMETERS }; // Mysql Handles MYSQL_RES *__mysql_res__; DBULONG _mysqlNumRows; DBULONG _mysqlCurrentRow; // Parameter collection. DBULONG _numParameters; MysqlBindParam **_parameters; // Field Information collection DBULONG _numFieldInformation; BaseFieldDescription **_fieldInformation; // Field Value collection DBULONG _numRecordValues; MysqlValue **_recordValues; MysqlConnection* _parentConnection; int _index; // Index of the handle object bool _isTransaction; // Is the object in a state of a transaction running. /* Internal method to obtain the information * about the fields returned in a result set. */ void _mysqlGetFieldsInformation(); /* Internal method to obtain the data in the result set row */ void _mysqlGetResultSetRow(); /* Internal method to return the dbConnect type for the mysql field * * @param type The MySQL field type to resolve to a dbConnect field type * * @return Returns the dbConnect field type for the given MySQL field type */ FieldType _mysqlResolveFieldType( enum_field_types 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 _mysqlParseBindParameters( 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. * */ MysqlQuery( MysqlConnection* parentConnection, int index); /* Destructor. * */ virtual ~MysqlQuery(); /* 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. * */ void transBegin(); /* Commit a transaction. * */ void commit(); /* Rollback a transaction. * */ 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 + -