Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Join the forums now, and start posting to receive access to our Scripts Vault!
Home
Forum
Help
Login
Register
BBGameZone.net
»
Webmasters
»
The Starting Line
»
Database abstraction layers
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: Database abstraction layers (Read 1679 times)
vizion
Level 7
Posts: 32
Reputation: +1/-0
Database abstraction layers
«
on:
October 17, 2007, 05:41:35 PM »
Is it really worth writing and/or using a database abstraction layer? I don't plan on ever changing from MySQL so what's the point of adding an extra layer of code for no apparent benefit at the cost of performance? Please don't try to convince me that one day I might switch to some other DBMS. Just tell me if a database abstraction layer is really worth it when portability is not a concern.
Logged
Zeggy
Global Moderator
Level 35
Posts: 1,187
Reputation: +13/-4
Re: Database abstraction layers
«
Reply #1 on:
October 18, 2007, 08:05:24 AM »
I use adoDB because it cleans out your SQL strings for you. It also has some useful functions to use.
You can also switch database types with less changes to SQL queries. It's not as easy as it sounds, but it does help a bit
Logged
Chris
Game Owner
Level 35
Posts: 2,217
Reputation: +28/-1
Re: Database abstraction layers
«
Reply #2 on:
October 18, 2007, 10:55:13 AM »
I don't see the point in using DBAL in games. In professional business software, forums, why not. But games?
1) The performance is the key, so any additional layer is not the best idea (bear in mind that servers for PBBGs are very expensive comparing to the income, many games struggle to even pay the bills)
2) MySQL is the cheapest one (Free, nothing can be chepaer than free, well, unless thay pay you for using it but it is quite rare
, very reliable and is available on all Linux packages I came across.
3) If you are forced to switch one day, why couldn't you be forced to switch the language as well? So, make an abstraction layer to make it work with PHP, Perl and Ruby as well
Logged
www.lordsgame.com
|
www.SamuraiMMORPG.com
|
www.Moonstone-RPG.com
|
www.GalacticImperator.com
|
Europe1300.eu
Zeggy
Global Moderator
Level 35
Posts: 1,187
Reputation: +13/-4
Re: Database abstraction layers
«
Reply #3 on:
October 18, 2007, 01:13:57 PM »
I might be wrong, but ADOdb is also available for other languages
Anyways, yeah, I see your point.
I use ADOdb because I'm used to it, and I prefer using it over plain mysql functions. I can't think of any other arguments right now
I don't really know all the details of ADOdb.
Logged
Sinzygy
Level 28
Posts: 420
Reputation: +11/-0
Re: Database abstraction layers
«
Reply #4 on:
October 18, 2007, 03:13:08 PM »
I use adodb as well. The reason? None actually. I just heard all the talk about it, started using it and simply was too lazy to switch back :p
Logged
codestryke
Administrator
Level 33
Posts: 589
Reputation: +22/-0
Re: Database abstraction layers
«
Reply #5 on:
October 18, 2007, 05:57:24 PM »
I don't plan on switching db's either but I keep with ADODB for a number of reasons....
1. Yes you pay a penalty because you are instancing a class, however, if you write good code you would basically (or should) create your own db wrapper to make things tidy and modularized. So why re-invent the wheel, IMHO.. I wrote my own DB handling class and used that for a number of years but when I round ADODB I switched.. The code is TIGHT, tighter then I wrote and it did what I was already doing so the switch was simple.. Drop ADODB into the include path of Apache and now it's available to any game I put on my server.
2. ADODB comes with a page called perfmon.php. This logs all your queries and then tells you which ones are taking to long, use improper indexes etc.. The data this monitor alone gives you is worth it's weight in gold. Games are based on performance and the slowest point of the game is always the database.
3. The GetAll syntax.. If possible ADODB library will try to use the compiled version of GetAll (mine does) and this has been a huge performance increase for my games and load off my server.. Instead of looping though a record set and putting the results in a array in PHP, it's done in C and is very fast...
4. Data caching.. nuff said.
With the reasons above it's not why should I use ADODB, it's more of a question of why you're not. Abstraction layers are always a bit of a performance lag but ADODB and SMARTY are the ones that actually give you an enormous amount of benifit compared to the maybe 4-10 cycles of processor speed they use..
Oh and if you ever add any type accelerator (pre compiler) then the performance reasons are mute.
Logged
Creating online addictions, one game at a time:
vizion
Level 7
Posts: 32
Reputation: +1/-0
Re: Database abstraction layers
«
Reply #6 on:
October 18, 2007, 10:10:56 PM »
I'll admit, that the main reason I even asked this question was a reluctance to learn how to use ADODB. I kinda didn't want to sit down and start reading pages and pages of documentation but I will if I have to. However, codestryke makes some very compelling points. Another reason I asked this question was because I found some benchmarks on the web and MySQL alone is twice as fast as ADODB. But ADODB is the fastest of the abtraction layers tested in the benchmarks I found. I did like how it made it easy to store sessions in the database.
Does anyone know of an ADODB tutorial or something that goes over the major points without having to sift through tons of technical documentation?
Also, codestryke, you advocate using a template system as well? I'm definitely leery of that.
Oh yeah, one last thing, by using ADODB am I required to make my code open source? I was reading the license and it seemed to imply that but I could have been misunderstanding the legalese. If being open source is a requirement then that's a serious negative.
«
Last Edit: October 18, 2007, 10:15:26 PM by vizion
»
Logged
codestryke
Administrator
Level 33
Posts: 589
Reputation: +22/-0
Re: Database abstraction layers
«
Reply #7 on:
October 20, 2007, 02:24:10 PM »
The ADODB manual online is very brief and if you already know mySQL commands it's a snap to pick up... Probably take ya all of 20 minutes playing around with it...
No you are not required to make you game open source if you use the ADODB library.. They state this somewhere in there documentation. If you do make changes to the ADODB library you will need to share you changes with the ADODB community.
Yes I'm a huge advocate of using a template system.. True separation of layout and code, using a template actually forces better programming standards.
Logged
Creating online addictions, one game at a time:
vizion
Level 7
Posts: 32
Reputation: +1/-0
Re: Database abstraction layers
«
Reply #8 on:
October 22, 2007, 04:35:55 PM »
Looking over the ADODB manual I see that it'll be better for me to use it. At least, it will save tons of time. Lots of people seem to dislike template systems but I think I will end up using Smarty. I actually learned PHP by playing around with the code on my phpBB forums so I'm used to how a template system works. I also really like that code is seperated from content. I find pages that are mixed together very hard to read. I don't like having to look extremely hard to find the one line of code that needs changing.
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
BBGameZone.net
»
Webmasters
»
The Starting Line
»
Database abstraction layers
SimplePortal 2.3.3 © 2008-2010, SimplePortal