Development Articles
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherDevelopment Articles

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 13th, 2002, 10:28 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
PEAR does not offer true database independence.

PEAR does not offer true database independence because it does not abstract field data type values like for instance JDBC does.

This means that PEAR does not handle the differences in format representations between databases.

Think for instance of Date fields. These are represented in different ways in different databases. If you need to process those field values in your application, you need handle the format representation differences in your application, making it database dependent.

If you would like to use a truely database independence abstraction package in PHP, try "Metabase":http://phpclasses.UpperDesign.com/ .

Metabase not only provides data type abstraction, but also abstracts database schema installation and maintenance.

This means that all you need to do to install and maintain a database schema, is to describe its tables, fields, indexes and sequences in a custom XML file.

Metabase takes care of the rest without requiring you to deal with the different ways to do that with the different types of databases.

Reply With Quote
  #2  
Old February 14th, 2002, 03:16 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
speed sacrifice?

does it slow down the execution of queries at all?

Reply With Quote
  #3  
Old February 14th, 2002, 04:33 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
PEAR and Windows..

1. My (early) PHP4 binary installation seemed to mishandle the PEAR part of the installation.
2. I haven't been able to find manual installation instructions - even hints seem to be aimed at UNIX users, which discourages experiment.
But, database Abstraction I could do with! Anybody got any pointers to manual installation instructions for Windows, please?

Reply With Quote
  #4  
Old February 14th, 2002, 09:34 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Re: speed sacrifice?

I saw about a 70% drop in performance when I plugged the PEAR DB class into some very simple scripts. I'd imagine it would just get worse as the queries and code got more complicated. I read somewhere that it's mainly to do with all the error-checking in the class, which is probably true. The fact that it's written in PHP doesn't help either.

I doubt most people will need database independence - it seems more like a fancy idea to get giddy about. The PEAR DB class is sort of in no-mans-land. It's overkill for anyone wanting a simple, standard DB interface to work with, and it's not at all fast enough for any serious use.

Reply With Quote
  #5  
Old February 14th, 2002, 11:33 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
insert_id ?

Every abstraction layer I have seen always seems to be missing some sort of insert_id like mysql_insert_id. is there such thing in the PEAR abastraction layer for this?

Reply With Quote
  #6  
Old February 14th, 2002, 02:58 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Database independence is a poor argument

Database independence is a poor argument for DB abstraction layers for a couple reasons. First, in the real world, people have things known as utilities or programming languages. Most text editors that I have worked with include the ability to ‘find and replace…’ text. It would be trivial for me to open up my code in Text Pad, do ‘find and replace’, check ‘all files’ and then have it replace ‘mysql_’ with ‘oracle_’. Pretty easy – no way would I ever expect someone to do that by hand unless they were looking at a particular file or the application is sufficiently small. Secondly, changing RDBMs’ isn’t something you do every day, nor should it be taken lightly. Expecting to not have to modify code is a false assumption for several reasons:

1) For all but the simplest SELECT statements most RDBMs’ SQL implementation differs enough that you’d have to re-write your complex queries. As shown in your example of transactions, Oracle uses sequences to create auto_incrementing integers. MySQL uses a column type of ‘auto_increment’ and requires you to explicitly insert NULL. Sybase and MS SQL use IDENTITY columns but requires that you leave the identity column OUT OF the SQL statement.

2) You should check EVERY SINGLE QUERY to make sure it performs well in your new environment. Oracle may use an index (or two) in a situation when MySQL will table-scan, causing your query to take 200x as long to complete. Switching your backend DB should not be a ‘fire and forget’ situation!

3) Most Enterprise RDBMs’ include the concept of Stored Procedures. These, actually, are a GREAT way to achieve DB independence (to some degree) in your application. For example, say you have some code like this:
*_query( “sp_get_user_info $userid” );
As long as my stored procedure is named the same, takes the same parameters, and behaves in the same manner I don’t have to change that line at all! I can write the SQL in Oracle’s PL/SQL, Sybase/MS SQL’s T-SQL, etc. and the application logic does not have to change.

However, DB abstraction layers are nice since you can include error checking and array-fetching very easily. I’d say the greatest advantage to using an abstraction layer are the class functions you create for it. To place the first and largest argument on ‘DB independence’ horribly weakens the story since anyone who as ever ported something over knows how incorrect of a statement that is.

--
Matt

Reply With Quote
  #7  
Old February 14th, 2002, 03:29 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
What about ADODB?


Available at <a href="http://freshmeat.net/projects/adodb/">http://freshmeat.net/projects/adodb/</a>

ADODB is a set of advanced PHP database wrapper classes. It supports MySQL, PostgreSQL, Interbase, Oracle, MS SQL 7, Sybase, DB2, FrontBase, Foxpro, Access, ADO, and generic ODBC. A metatype system is built in, making it possible to figure out that types such as CHAR, TEXT, and STRING are equivalent in different databases. It also features an SQL to HTML popup menu and SQL to HTML table support.

ADODB has been around for a while now. It's easy to port to different databases using a configuration file to specify your database type.

Reply With Quote
  #8  
Old February 14th, 2002, 03:59 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Re: What about ADODB?

I agree with cschilbe here, ADODB is a very nice system. I've found that most of the PEAR things are not very well designed. They seem to 1/2-assed attempt modularity. They better get their act together if they plan on being anything like CPAN is for perl (which is why they started PEAR).

I also find it interesting that the author is "ashamed" that he used to use a greatly superior language (perl), and now feels at home with the weak constructs of php.

Reply With Quote
  #9  
Old February 14th, 2002, 04:02 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Re: Re: What about ADODB?

Haha, good point Jon!

Reply With Quote
  #10  
Old February 15th, 2002, 07:55 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
MySQL Doesn't Support Transactions?

It didn't used to support transactions, but it surely does now. Much thanks to Gemini, BDB and InnoDB table types.

Reply With Quote
  #11  
Old February 16th, 2002, 08:07 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Security bonus of using PEAR DBI

Recent security reports have made a lot of play about the possibility of malicious user input being able to subvert SQL queries by altering the way they are parsed, and the PHP/MySQL interface does not make it easy to avoid the issues.

The *Perl* DBI offers a good way to handle user input securely using placeholders together with the prepare()/execute() combination. This works because there need be no user-supplied data in the string passed to prepare(), which is where the query is parsed; the user-supplied values are passed instead to the execute() call, where they cannot affect the parsing.

If the *PEAR* DBI prepare()/execute() handles queries in the same manner, this may be the strongest reason to adopt it, regardless of concerns about performance loss.

Provided the execute() function does not re-parse the query, but merely substitutes the user-supplied values in the pre-parsed query (as is implied by Icarus's article), the security benefits of this should be present in the PEAR DBI.

Reply With Quote
  #12  
Old February 18th, 2002, 05:02 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Re: What about ADODB?

I've been trying to choose the best DAL for a while now and I've tried Metabase, PEAR, phpLib, ADODB.

Here are my experiences...
Metabase looks complicated, very promising and I was exited to use it because apparently it should be easy to port ur applications to different databases. Not depended on compilation of server extensions.

PEAR, I'm using Apache and Windows2000 to develop my app before using it on a linux machine but there isn't any documentation to install it on win2000. I was just going to develop my app on linux but my ISP doesn't provide PEAR support. So it seems like that I won't be creating apps depended on a software that has to be compiled on the server.

phpLib, It works ok, not depended on extensions or PEAR, but some database drivers aren't fully developed.

I've tried ADODB and it's easy to use...
You only need to include 1 core file to do all the important functions and other files to do optional handy features. I like it...

Reply With Quote
  #13  
Old February 22nd, 2002, 04:41 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

Reply With Quote
  #14  
Old February 22nd, 2002, 12:23 PM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

Reply With Quote
  #15  
Old February 23rd, 2002, 03:59 AM
guest
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherDevelopment Articles > Database Abstraction With PHP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |