Skip to content

Commit 58ebc11

Browse files
committed
Updated README.md
1 parent dc7a0c9 commit 58ebc11

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

README.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,32 @@ Example main func:
2323
#include <wsjcpp_sql_builder.h>
2424

2525
int main(int argc, const char* argv[]) {
26-
WsjcppSqlBuilderInsert sql("TABLE_NAME");
27-
sql.add("COL1", "val1"); // will be escaped
28-
sql.add("COL2", 1);
29-
// sql.add("COL3", 1.1);
30-
if (!sql.isValid()) {
31-
std::cerr << "Something wrong with query: " << sql.getErrorMessage() << std::endl;
32-
return -1;
33-
}
34-
std::cout << sql.getTextQuery() << std::endl;
35-
return 0;
26+
WsjcppSqlBuilder2 builder;
27+
builder.selectFrom("table1")
28+
.colum("col1")
29+
.colum("col2", "c3")
30+
.colum("col3")
31+
.colum("col4")
32+
.where()
33+
.equal("col1", "1")
34+
.or_()
35+
.notEqual("col2", "2")
36+
.or_()
37+
.subCondition()
38+
.equal("c3", "4")
39+
// .and_() // be default must be added and
40+
.equal("col2", "5")
41+
.finishSubCondition()
42+
.or_()
43+
.lessThen("col4", 111)
44+
.endWhere() // need only for groupBy havingBy and etc
45+
;
46+
std::cout << builder.sql() << std::endl;
3647
}
3748
```
3849
3950
Example output:
4051
```
4152
$ ./wsjcpp-sql-builder
42-
INSERT INTO TABLE_NAME(COL1, COL2) VALUES ('val1', 1);
53+
SELECT col1, col2 AS c3, col3, col4 FROM table1 WHERE col1 = '1' OR col2 <> '2' OR (c3 = '4' AND col2 = '5') OR col4 < 111
4354
```

0 commit comments

Comments
 (0)