Skip to main content
gamedev.net
🔒 Locked

C++ interface to Database Table

Started by Xues32 Mar 25, 2009 at 2:25 AM 2 replies 1.1k views
Original Post
Xues32
Xues32
In my application, I have large number of data table so, I have decided to use db to store the data! In my first implementation, I have made a class big class that hold all call to the database. Now I have a lots of table and this class became difficult to manage. Now, there's a good way to implement data table interface on OO language? Thanks Xeus32
ToohrVyk
ToohrVyk
The simplest way is to use an ORM.

Or do you insist on performing the mapping yourself?
Xues32
Xues32
I don't think I can do it on c++, good new. I use the same approach on C#.
My best limitation is that my application work on linux, windows and mac (not yet)!
As db I use sqlite and PostgreSQL and I use 3 different compiler!
cignox1
cignox1
In our project we did the mapping ourself, by using much reflection and OO design to automatize common task (selects, inserts and so on). I works on Windows and linux. I can't give you source code, but essentially we have a base DBWrapper class wich has several virtual methods (Add, Delete, Select, ...). Adding a new table only means writing a simple class wich contains the properties (get,set) of each field. An attribute to the class specifies the name of the table, and an attribute for each property specifies the name of the column.

Of course, there are ORM that do the same things. I personally used only one of them (telerik) and found it complex and not really flexible (weak support for nested or named transactions, for example), but I just gave it a look because a friend of mine was working with it, so I can only say my small experience.

EDIT: we did it in C# on PostgreSQL

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.