473,323 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

To abstract or not

All,
A ways back I setup my db access PHP file to support either MySQL or MSQL.
Now, I am sticking w/MySQL. For performance reasons, should I replace my
generic functions w/the raw MySQL ones ?

For example, I had this (from PHPNuke):

function sql_connect($host, $user, $password, $db)
{
global $dbtype;
switch ($dbtype)
{
case "MySQL":
$dbi = @mysql_connect($host, $user, $password);
return $dbi;
break;;

case "mSQL":
$dbi = msql_connect($host);
return $dbi;
break;;

default:
break;;
}
}

and now I can just use mysql_connect instead of going through the extra file
and functions and calling sql_connect.

Comments ?
Jul 17 '05 #1
3 1536
m|sf|t wrote:
All,
A ways back I setup my db access PHP file to support either MySQL or MSQL.
Now, I am sticking w/MySQL. For performance reasons, should I replace my
generic functions w/the raw MySQL ones ?


The code you posted isn't likely to generate a significant load compared
with, say actually retrieving data from the database - definitely not worth
bothering about for perfomrance reasons.

HTH

C.
Jul 17 '05 #2
"m|sf|t" <m|****@ampsycho.com> wrote in message news:<10*************@corp.supernews.com>...
All,
A ways back I setup my db access PHP file to support either MySQL or MSQL.
Now, I am sticking w/MySQL. For performance reasons, should I replace my
generic functions w/the raw MySQL ones ?


Do you expect your project to grow and change? Where do you think it
will be in two years? Will you have to adapt it to other databases in
the future? Are there side-benefits to the abstraction, like allowing
rich error messages, or catching function calls that shouldn't be made
because of a previous error? Will you be adding new features?

Abstraction is an insurance policy. You want that insurance against
future change, if you think your project is going to change. It is
slightly expensive in terms of performance. Ask yourself if your
project needs that insurance.
Jul 17 '05 #3
"m|sf|t" <m|****@ampsycho.com> wrote in message news:<10*************@corp.supernews.com>...
All,
A ways back I setup my db access PHP file to support either MySQL or MSQL.
Now, I am sticking w/MySQL. For performance reasons, should I replace my
generic functions w/the raw MySQL ones ?

For example, I had this (from PHPNuke):

function sql_connect($host, $user, $password, $db)
{
global $dbtype;
switch ($dbtype)
{
case "MySQL":
$dbi = @mysql_connect($host, $user, $password);
return $dbi;
break;;

case "mSQL":
$dbi = msql_connect($host);
return $dbi;
break;;

default:
break;;
}
}


Abstraction is obviously an overhead, but there is large benefits
when your project grow or you want to change your DB. So, I always
prefer abstraction like the one used by phpBB; the above is tooooo
overhead.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Merlin | last post by:
Hi Been reading the GOF book and started to make the distinction between Class and Interface inheritance. One question though: Do pure abstract classes have representations? (data members?)...
2
by: Dave Veeneman | last post by:
Is is legal to declare abstract members in non-abstract classes? How about non-abstract members in abstract classes? I am writing a base class with three derived classes. The base class will...
6
by: Dan Sikorsky | last post by:
If we were to define all abstract methods in an abstract class, thereby making that class non-abstract, and then override the heretofore 'abstract' methods in a derived class, wouldn't that remove...
5
by: Tony Johansson | last post by:
Hello!! Assume you have an Interface called ITest with these three method declarations. interface ITest { void foo1(); void foo2(); void foo3(); }
7
by: jason | last post by:
In the microsoft starter kit Time Tracker application, the data access layer code consist of three cs files. DataAccessHelper.cs DataAcess.cs SQLDataAccessLayer.cs DataAcccessHelper appears...
0
by: mailforpr | last post by:
Hi. Let me introduce an iterator to you, the so-called "Abstract Iterator" I developed the other day. I actually have no idea if there's another "Abstract Iterator" out there, as I have never...
0
by: emin.shopper | last post by:
I had a need recently to check if my subclasses properly implemented the desired interface and wished that I could use something like an abstract base class in python. After reading up on metaclass...
4
by: David Zha0 | last post by:
Hi, "when we call a virtual method, the runtime will check the instance who called the method and then choose the suitable override method, this may causes the performance drop down", is this...
6
by: Miguel Guedes | last post by:
Hello, I recently read an interview with Bjarne Stroustrup in which he says that pure abstract classes should *not* contain any data. However, I have found that at times situations are when it...
5
by: Tony Johansson | last post by:
Hello! Here I have an Interface called ITest and a class called MyClass which derive this intrface. As you can see I don't implement this method myTest in class MyClass because i use the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.