This project is read-only.
Project Description
Class C++ of parse SQL query. Simple, but effective to add a condition to the SQL query of any complexity or replace a variable by its value. Variable begins with a '$'.

Create an object type IAZSQL::ParseSQL. As a parameter of the constructor must specify the SQL request like "SELECT FROM", which may contain variables of the form "$ID". Variable begins with a '$'. Unlimited number of variables. Change of variables for their value is performed by IAZSQL::AddVariable(...). In addition, the class supports the addition of conditions to the request. If necessary, will be added to the block "WHERE", you worry about it is not necessary. Add condition method can be IAZSQL::AddCondition(...).

Example of the use of class ParseSQL

#include "parsesql.h"
		IAZSQL::ParseSQL parse(L"SELECT FirstName AS Name, LastName, MiddleName FROM People WHERE ID=$ID GROUP BY Name,LastName,MiddleName");

		std::wcout << L"List of columns name:" << std::endl;

		IAZSQL::ParseSQL::StringVector columns;

		std::for_each (columns.cbegin(), columns.cend(), [](const std::wstring& colname)
			std::wcout << colname << L",";
		std::wcout << std::endl;

		parse.AddVariable(L"ID", L"1"); // replace of "$ID" to "1"
		parse.AddCondition(L"AND LastName='Zharkov'"); // added condition

		std::wcout << parse.SQL<std::wstring>() << std::endl;
	catch (IAZSQL::ParseException& ex)
		std::wcout << ex.Message() << std::endl;


List of columns name:

SELECT FirstName AS Name, LastName, MiddleName FROM People WHERE ID=1 AND LastName='Zharkov' GROUP BY Name,LastName,MiddleName

Last edited Jan 15, 2011 at 7:11 PM by iaz, version 6