What's new

[C++] Query builder library

Jack Sparrow

Gold Supporter
Gold Supporter
Joined
Jul 9, 2015
Messages
343
Reaction score
37
https://github.com/Artamedes/QueryBuilderTest

Query builder C++ I have been working on

How to use example: https://github.com/Artamedes/QueryBuilderTest/blob/master/Main.cpp#L7

At the moment there are 3 types: INSERT, REPLACE, UPDATE

Code:
    QueryBuilder l_Builder(QueryTypes::Update, "item_template");

    l_Builder.AddColumn(0, DataType::Key, "entry", "1337");
    l_Builder.AddColumn(0, DataType::Key, "class", "2");
    l_Builder.AddColumn(0, DataType::None, "subclass", "7");
    l_Builder.AddColumn(0, DataType::None, "name", "Lost sword of the four gods");
    l_Builder.AddColumn(0, DataType::None, "inventorytype", "13");
    l_Builder.AddColumn(0, DataType::None, "description", "Idk a god damn description");
    l_Builder.AddColumn(0, DataType::None, "stat_type1", "3");
    l_Builder.AddColumn(0, DataType::None, "stat_value1", "3333");

    l_Builder.AddColumn(1, DataType::Key, "entry", "1337420");
    l_Builder.AddColumn(1, DataType::None, "class", "2");
    l_Builder.AddColumn(1, DataType::None, "subclass", "7");
    l_Builder.AddColumn(1, DataType::None, "name", "Lost sword of the fifth gods");
    l_Builder.AddColumn(1, DataType::None, "inventorytype", "17");
    l_Builder.AddColumn(1, DataType::None, "description", "Idk a god damn description LoL");
    l_Builder.AddColumn(1, DataType::None, "stat_type1", "4");
    l_Builder.AddColumn(1, DataType::None, "stat_value1", "5555");
The params of QueryBuilder are QueryType and Table Name

then you add columns for each row you want to insert, starting with 0 like so in the example.

Then when you're done with that you generate the query string with l_Builder.Generate() which returns a std::string

It's useful if you want to make something like an item creator or so.

Example Output:

 
Top