I was thinking if I were to implement this instead of using an already existing library or ORM, how would it turn out in C++.
Unfortunately we don't have the luxury of creating new class members dynamically on the fly in C++ (good if you care about speed). So it looks like one libraries overload the << operator, normal query with variables in between, while another has complex syntax and iterators but more flexibility.
I want a simple, understandable interface. Yet it needs to be flexible enough for all SQL operations (and thus multiple scope levels, recursion, etc.)
So I ask, what are some decent ways of interfacing with databases you've seen in C++?
I wonder if this, as usage, would be a decent direction:
Code:
Linker linker;
Row r = linker
.Select()
.Fields()
.Field("*")
.And()
.Count("some_category").As("all")
.End()
.From()
.Table("some_table")
.And()
.Table("another_table")
.End()
.Where()
.Field("some_field").EqualTo(10)
.Or()
.Where()
.Field("another_field").EqualTo(20)
.And()
.Field("this_field").EqualTo("abc")
.And()
.Where()
.Field("some_field").EqualTo(10)
.Or()
.Field("another_field").EqualTo(20)
.End()
.End()
.Or()
.Where()
.Select()
.Fields()
.Field("*")
.End()
.Where()
.Field("this_field").BiggerThan(50)
.End()
.End()
.End()
.End()
.Load();
Row would store the query object, the query object would have pointers to the variables so it could be updated/saved/deleted.
Reason I ask is I'm not familiar with existing methods, as I've normally used the low-level libraries and pure sql strings. As well as not wanting to waste more time on something that may be stupid.
Thanks in advance. I know it might be a waste of a topic, but it can't hurt to ask.