Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Sep 21, 2018 4:47 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Generic Database object
PostPosted: Thu Apr 04, 2013 8:51 pm 
Offline

Joined: Mon Nov 01, 2010 6:28 pm
Posts: 24
I've been experimenting with the generic database object trying to find the best way to create a subclass that I can return the correct database object based upon a passed parameter.

I would like to do this so i can just use a generic name and have a class that would handle all of the necessary settings based upon the parameter.

How have some of you handled connecting to a variety of database types and maintain a generic object for you application?

I would welcome any database related examples that might be able to point me in the right direction.

I am able to connect to a variety of databases properly I just would really like to have a good generic interface.

Thank you,
Dwane


Top
 Profile  
Reply with quote  
 Post subject: Re: Generic Database object
PostPosted: Thu Apr 04, 2013 9:31 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
You cannot achieve this with a subclass of Database. What you can do, is make a generic class with no Super that contains a Database object as a property. Give that class all the methods that the Database class has. Make getter/setter methods to match all the properties of the database class. Now you can treat your new class just like a database object in code and have that class pass all the commands, etc., to the appropriate kind of database object.


Top
 Profile  
Reply with quote  
 Post subject: Re: Generic Database object
PostPosted: Fri Apr 05, 2013 8:32 am 
Offline

Joined: Mon Nov 01, 2010 6:28 pm
Posts: 24
Quote:
Give that class all the methods that the Database class has. Make getter/setter methods to match all the properties of the database class. Now you can treat your new class just like a database object in code and have that class pass all the commands, etc., to the appropriate kind of database object.


I follow your logic and that was the road I was originally heading down. One of the issues I stumbled upon was figuring out how to hand back the proper object through my generic object. I'm sure it's something I just haven't grasped about the realbasic language in comparison to some of the other languages I'm more familiar with.


Top
 Profile  
Reply with quote  
 Post subject: Re: Generic Database object
PostPosted: Fri Apr 05, 2013 12:04 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
The only object you should have to "hand back" is a recordset. Otherwise, your new class IS the database object as far as the rest of your code is concerned.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group